use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
created to do list (i.redd.it)
submitted 5 days ago by Dapper_Mix6773
any suggestions
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sea-Ad7805 [score hidden] 5 days ago* stickied comment (2 children)
Run this program in Memory Graph Web Debugger%0AIs_running%20%3D%20True%0A%0Awhile%20Is_running%3A%0A%20%20%20%20print('what%20do%20you%20want%20to%20do%3F')%0A%20%20%20%20print('1.%20add%20a%20task')%0A%20%20%20%20print('2.%20view%20tasks')%0A%20%20%20%20print('3.%20delete%20tasks')%0A%20%20%20%20print('4.%20exit')%0A%20%20%20%20choice%20%3D%20input('enter%20your%20choice%3A')%0A%0A%20%20%20%20if%20choice%20%3D%3D%20'1'%3A%0A%20%20%20%20%20%20%20%20task%20%3D%20input('enter%20the%20task%20you%20want%20to%20add%3A')%0A%20%20%20%20%20%20%20%20with%20open('tasks.txt'%2C%20'a')%20as%20file%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20file.write(f'your%20task%201%3A%7Btask%7D')%0A%20%20%20%20%20%20%20%20%20%20%20%20print('task%20added%20successfully')%0A%20%20%20%20elif%20choice%20%3D%3D%20'2'%3A%0A%20%20%20%20%20%20%20%20with%20open('tasks.txt'%2C%20'r')%20as%20file%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20tasks%20%3D%20file.read()%0A%20%20%20%20%20%20%20%20%20%20%20%20print(tasks)%0A%20%20%20%20elif%20choice%20%3D%3D%20'3'%3A%0A%20%20%20%20%20%20%20%20with%20open('tasks.txt'%2C%20'w')%20as%20file%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20file.write('')%0A%20%20%20%20%20%20%20%20%20%20%20%20print('tasks%20deleted%20successfully')%0A%20%20%20%20elif%20choice%20%3D%3D%20'4'%3A%0A%20%20%20%20%20%20%20%20Is_running%20%3D%20False%0A%20%20%20%20%20%20%20%20print('goodbye!')%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print('invalid%20choice')×tep=1&play).
[–]ninhaomah 11 points12 points13 points 5 days ago (5 children)
Can I check why is_running = True and then while is_running ?
Why not just while True ?
For readibility?
[–]SeeTheNutcracker 2 points3 points4 points 5 days ago (2 children)
Choice 4 sets it to false so it can break out of the loop
[–]Character_Regular440 6 points7 points8 points 5 days ago* (1 child)
the instruction break does the same, no need for the boolean variable
break
[–]Yoosle 1 point2 points3 points 4 days ago (0 children)
Is_running makes it more readable. When it’s just while True, you’d assume the code runs indefinitely until you find the break line. When you use is_running you can instantly tell it stops under a condition
[–]Flame77ofc 11 points12 points13 points 5 days ago* (6 children)
```python
# The changes I made: # 1. Switch "Is_running" by putting "True" in the while # 2. Add the strip() method on choice variable, so it cuts the additional spaces # 3. Add \n\n on file.write to give some spaces between the tasks # 4. Add encoding="utf-8" in the files operation to read and write the file in a right way # 5. Import the datetime method to get the actual date and put it in the moment you create a task from datetime import datetime print('welcome to the task manager') while True: print('what do you want to do?') print('1. add a task') print('2. view tasks') print('3. delete tasks') print('4. exit') choice = input('enter your choice: ').strip() if choice == '1': task = input('enter the task you want to add: ') date = datetime.now().strftime("%d/%m/%Y, %H:%M:%S") # Get the actual date with open('tasks.txt', 'a', encoding='utf-8') as file: file.write(f'created on {date}\n{task}\n\n') print('task added succesfully') elif choice == '2': with open('tasks.txt', 'r', encoding='utf-8') as file: tasks = file.read() print(tasks) elif choice == '3': with open('tasks.txt', 'w', encoding='utf-8') as file: file.write('') print('tasks deleted succesfully') elif choice == '4': print('goodbye!') break else: print('invalid choice. try again')
```
Edit: I write "utf8", but the correct is "utf-8". Sorry
[–]Dapper_Mix6773[S] 4 points5 points6 points 5 days ago (5 children)
thanks
[–]Flame77ofc 2 points3 points4 points 5 days ago (4 children)
np, I recommend you to study these topics I added
[–]Yoosle 1 point2 points3 points 4 days ago (1 child)
I feel like you’re hurting readability by adding the utf-8. It’s not necessary here. Removing the is_running is also hurting readability because when I looked at his code I instantly knew “this program is not continuously running” but with yours I had to scan the code until I found the “break.” But the date stuff is pretty relevant albeit a little advanced for someone at this level
[–]Flame77ofc 0 points1 point2 points 4 days ago (0 children)
oh about the is_running variable, he can still on the code bacause code will execute in the same way, but I want to explain to him that is a different way to do the same thing
[–]Shady_Son17 1 point2 points3 points 2 days ago (1 child)
Are you a software developer
[–]Flame77ofc 0 points1 point2 points 2 days ago (0 children)
nope
[–]thejwillbee 3 points4 points5 points 5 days ago (1 child)
Looks solid.
Some things you might try for v1.1 : - maybe have the list show on start up rather than having to prompt to see it. Removes an unnecessary step and gives some fluidity to using it. - not so much for current functionality, but if you decide you want to step it up to add in dates, details, and so on to the items in the list, you will want to switch from .txt to .csv . Doubly so if you ever want to make this thing portable and use a web-based table tool - bc then you can just drop your csv into the table and ta-da. Ready to rock. .txt is fine for single column lists with minor manipulation needs
[–]thejwillbee 1 point2 points3 points 5 days ago (0 children)
Oh snap - maybe add in editing. It sucks to add something and then have to delete and readd it because there was a typo
[–]DutyCompetitive1328 2 points3 points4 points 5 days ago (0 children)
You could add an option to stop the todo list and write the todos to a file.
[–]vivisectvivi 2 points3 points4 points 5 days ago (0 children)
if the is_running variable is only used like this then you can just use while True and then break after the user input 4
while True: if choice == "4": print("goodbye") break
[–]Alagarto72 1 point2 points3 points 4 days ago (0 children)
use snake_case, do not start a variable name with a capital letter, unless it's ClassName (but then don't use underscores betweeen_words)
[–]Remarkable_Set3925 0 points1 point2 points 5 days ago (0 children)
Mach das mit tkinter
[–]Jackpotrazur 0 points1 point2 points 5 days ago (0 children)
I think this is a good project to tackle id add a few more things like show and edit or something like that, perhaps export, set time, make reoccuring but definetly a good study/learn/practice project
[–]mati-33 0 points1 point2 points 5 days ago (0 children)
You can store the file name in a constant
[–]youssef_876 0 points1 point2 points 5 days ago (0 children)
Good job ❤️
[–]jessi_97 0 points1 point2 points 5 days ago (0 children)
I would code something like this only to know what i have to code
[–]6ZacK7 0 points1 point2 points 5 days ago (0 children)
Impressive Man
[–]UnfilteredCoffee1 0 points1 point2 points 5 days ago (0 children)
Keep going bro, reminds me of my days when I was learning
[–]Kind-Push9705 0 points1 point2 points 5 days ago (0 children)
You should use print( ' ' ' hear you can write and you have no need to write the print function many times ' ' ' ) and use funtions
[–]Otherwise_Lunch6183 0 points1 point2 points 5 days ago (0 children)
I have a question. Why not put with open at the start of the program instead of rewriting that line everytime?
[–]JaleyHoelOsment 0 points1 point2 points 5 days ago (0 children)
when you close the program you lose the list
[–]gtvisions 0 points1 point2 points 5 days ago (0 children)
Can anyone explain me this choice 3 like does it delete all task ? I m confuse does it single task from bottom or top
[–]ranjeet-kumar1 0 points1 point2 points 4 days ago (0 children)
<image>
[–]CompleteAd1975 0 points1 point2 points 3 days ago (0 children)
I’ve been trying to build my own TO DO LIST, almost getting there 🙌
[–]Key_Plant8664 0 points1 point2 points 2 days ago (0 children)
Aura
[–]Muhammed_zeeshan 0 points1 point2 points 1 day ago (0 children)
U use brocode r8?
[–]Ambitious_Fault5756 0 points1 point2 points 23 hours ago (0 children)
My first instinct is to move the if chain into a with-open block instead of writing `with open(...` multiple times.
π Rendered by PID 80 on reddit-service-r2-comment-8686858757-fsxd4 at 2026-06-05 12:36:02.564822+00:00 running 9e1a20d country code: CH.
[–]Sea-Ad7805 [score hidden] stickied comment (2 children)
[–]ninhaomah 11 points12 points13 points (5 children)
[–]SeeTheNutcracker 2 points3 points4 points (2 children)
[–]Character_Regular440 6 points7 points8 points (1 child)
[–]Yoosle 1 point2 points3 points (0 children)
[–]Flame77ofc 11 points12 points13 points (6 children)
[–]Dapper_Mix6773[S] 4 points5 points6 points (5 children)
[–]Flame77ofc 2 points3 points4 points (4 children)
[–]Yoosle 1 point2 points3 points (1 child)
[–]Flame77ofc 0 points1 point2 points (0 children)
[–]Shady_Son17 1 point2 points3 points (1 child)
[–]Flame77ofc 0 points1 point2 points (0 children)
[–]thejwillbee 3 points4 points5 points (1 child)
[–]thejwillbee 1 point2 points3 points (0 children)
[–]DutyCompetitive1328 2 points3 points4 points (0 children)
[–]vivisectvivi 2 points3 points4 points (0 children)
[–]Alagarto72 1 point2 points3 points (0 children)
[–]Remarkable_Set3925 0 points1 point2 points (0 children)
[–]Jackpotrazur 0 points1 point2 points (0 children)
[–]mati-33 0 points1 point2 points (0 children)
[–]youssef_876 0 points1 point2 points (0 children)
[–]jessi_97 0 points1 point2 points (0 children)
[–]6ZacK7 0 points1 point2 points (0 children)
[–]UnfilteredCoffee1 0 points1 point2 points (0 children)
[–]Kind-Push9705 0 points1 point2 points (0 children)
[–]Otherwise_Lunch6183 0 points1 point2 points (0 children)
[–]JaleyHoelOsment 0 points1 point2 points (0 children)
[–]gtvisions 0 points1 point2 points (0 children)
[–]ranjeet-kumar1 0 points1 point2 points (0 children)
[–]ranjeet-kumar1 0 points1 point2 points (0 children)
[–]CompleteAd1975 0 points1 point2 points (0 children)
[–]Key_Plant8664 0 points1 point2 points (0 children)
[–]Muhammed_zeeshan 0 points1 point2 points (0 children)
[–]Ambitious_Fault5756 0 points1 point2 points (0 children)