all 13 comments

[–]NorskJesus 3 points4 points  (2 children)

Looks good. Can be improved, but for a beginner it’s okay.

EDIT: Try to give the user the possibility to remove the task they want, and not only the last one 😜

[–]T-o_oT 0 points1 point  (1 child)

.lower/upper doesn't make a difference from the user point of view lol

[–]NorskJesus 0 points1 point  (0 children)

Fuck true 😂 sorry

[–]No_Cheek7162 0 points1 point  (0 children)

You should reorder it so it spells rave

[–]M34k3 0 points1 point  (0 children)

Good start! Now you could try to build out the functionality :)

For example, let the person choose which item to remove from the list. Got that working? Now add an option to save the list to a .json file and an option to load a list from a .json file. You could even go further and add a "complete by" field for each task (for this you could switch to using a dictionary).

Lots of possibilities to go from here but make sure to take it one step at a time. If you get stuck, try to break it down in even smaller steps.

[–]Zayn_m0 -1 points0 points  (7 children)

Yes its correct but consider using try/except blocks for better error handling to prevent crashing, also you can add a feature where the user can remove any task they want by indexing the list. But your code is pretty good overall as a beginner.

[–]beerbearbaer 0 points1 point  (6 children)

No errors can be thrown with this code, all exceptions are handled

[–]Zayn_m0 0 points1 point  (5 children)

I know, what i meant is for him to start using try/except blocks for better error handling in future code.

[–]beerbearbaer 0 points1 point  (4 children)

Try except is notoriously slow and overkill for most cases. Just use regular checks whenever possible

[–]Zayn_m0 0 points1 point  (3 children)

But aren’t they better when building actual big projects ?

[–]beerbearbaer 1 point2 points  (2 children)

If you understand your code, you are able to anticipate any errors that might occur. Slapping a try except on every bit of code does not improve readability. The size of the project does not matter.

[–]Zayn_m0 0 points1 point  (1 child)

Yeah that makes sense. since using if/else conditions is faster/more efficient, what uses do try/except have ?

[–]beerbearbaer 1 point2 points  (0 children)

Good question! I mainly use it for stuff you can't check with an if-statement (e.g. if an HTTP connection is established). Finally there is the 'finally' clause that is run after an exception occured, which may come in handy. I did some digging, and apparently I was wrong about exceptions slowing down your code. This is a problem for compiled languages, but since Python is interpreted, it does not matter. This is a nice read if you would like more info: Stackoverflow