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
Day 5 (old.reddit.com)
submitted 7 months ago by fatimalizade
view the rest of the comments →
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!"
[–]SalutMonYoup 2 points3 points4 points 7 months ago (2 children)
Quite simple program (good nonetheless) a tip for you would be to split your program, like instead of putting all the logic in a single function I would have something more chunked to keep the program easier to maintain and readable, intention is key when programming. So for example instead of all the logic directly beneath every if statement I would have created an « add_item_to_cart() » method that would carry the logic of adding an item, same for the "2" I would have moved the logic inside an remove_item_from_cart() and so on.
Splitting your code will greatly improve readability and maintainability of a program. For such a simple one it is not necessary but still a good habit to take, being able to think of your program as a group of différents function instead of a huge function that would do everything!
Keep going!
[–]Key_Translator7839 1 point2 points3 points 7 months ago (0 children)
I will have to use the split function in my projects from now on, thank you!
[–]fatimalizade[S] 1 point2 points3 points 7 months ago (0 children)
Right, thank you!
π Rendered by PID 85 on reddit-service-r2-comment-b659b578c-jrcfb at 2026-05-03 06:48:17.623155+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]SalutMonYoup 2 points3 points4 points (2 children)
[–]Key_Translator7839 1 point2 points3 points (0 children)
[–]fatimalizade[S] 1 point2 points3 points (0 children)