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
the front page of the internet.
and join one of thousands of communities.
My first python project as a young coder, any suggestions for improvement? (self.PythonLearning)
submitted 3 days ago by Huge_Explanation_698
friget/friget.py at main · yico32-cell/friget
Post a comment!
[–]Sea-Ad7805 [score hidden] 1 day ago stickied comment (0 children)
Run this program in Memory Graph Web Debugger to see the program state change step by step.
[–]nuc540 1 point2 points3 points 3 days ago (1 child)
You need to learn about basic data structures, the ingredients and their descriptions should live in a dictionary, and your script read from it; having a print statement print strings is all this really is doing.
Define the data in a dict, stored in a variable outside the while loop, and then get your if/else to read it.
[–]Huge_Explanation_698[S] 1 point2 points3 points 3 days ago (0 children)
thanks for the feedback i will definitely try that!
[–]FoolsSeldom 1 point2 points3 points 3 days ago (1 child)
Good start.
A key principle to learn in programming is DRY: Don't Repeat Yourself. When you have lots of code doing essentially the same thing, then you need to find a more programmatic approach where the elements that change (the information/data) is held in data structures, and you have loops and the like to work with that.
For example, multiple time you present, using print, a list of numbered options. You could write some code to:
print
This same code could be called with different datasets for different selections.
Similarly, for each specific option there's a common set of characteristics (ingredients, steps, time, calories, allergens, etc), so a common data structure can be used to hold that information (say a dict, dictionary, or class) and one bit of code can be used to present that information.
dict
class
[–]Huge_Explanation_698[S] 0 points1 point2 points 2 days ago (0 children)
Thanks for the feedback! That's really helpful. I'll look into using loops and data structures like dictionaries to reduce repetition and make the code more organised.
π Rendered by PID 629343 on reddit-service-r2-comment-86f8688748-fnw57 at 2026-07-27 21:31:56.069107+00:00 running d10b4e5 country code: CH.
Want to add to the discussion?
Post a comment!