I'm a beginner in Python and just wrote some code to manage tasks, but I'm looking for feedback on how I can enhance it. I'm still learning about functions and variable handling, so I was mainly testing my current skills without any external help. How well did I do on a scale of 0-10? What should I focus on to improve my code? Here's a brief overview of my program:
- It allows users to view and add tasks in a loop until they choose to exit.
- I handle user input with a series of if statements, but I'm not sure if that's the best approach.
- I've included some print statements for user prompts, but I worry it could be improved for clarity.
Any thoughts or suggestions would be greatly appreciated!
3 Answers
You're off to a solid start! To make your code cleaner, consider breaking it into functions for handling tasks since you're repeating the same logic multiple times. Also, instead of using a variable to control your while loop, you can simplify it to just `while True:`. Additionally, be careful when casting user input to an integer right away; it's better to use try/except to manage unexpected inputs. Keep practicing and you’ll get the hang of it!
Nice attempt! Your comments really enhance clarity. I recommend focusing on functions next because a lot of your code repeats the same structure. Reducing redundancy makes your code cleaner. For user prompts, think about giving clear options together so users don't get confused about what to do next. Overall, I'd rate this code a 7/10! Keep pushing yourself and learning!
Thank you! I'm definitely going to focus on learning functions next. I agree that clarity is essential, and I appreciate your feedback!
The code seems good for a newcomer! One suggestion is to have all actions available from the start, so users don't feel forced to view tasks first. Try re-arranging your flow to make it more intuitive. Also, using `choose = input('prompt here > ').strip()` for input captures any leading or trailing spaces and makes it safe for checking conditions later on. Great job on the comments, they help a lot!
What does .strip() do? I'm not familiar with it.
It removes any whitespace from the beginning and end of the input! Helps prevent unintended errors.

Thanks for the tips! I'll definitely look into using functions and improving input handling.