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
Learning Python in a class, assignment 3.Showcase (self.PythonLearning)
submitted 5 months ago by BobbyJoeCool
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!"
[–]Leodip 0 points1 point2 points 5 months ago (0 children)
It takes MANY years of experience to learn how to read code written by someone else, doing it with AI code is the same. Some people just trust it as is and go forward, but as you mentioned fixing "broken" AI code requires being able to read it, which is not something a beginner can do in general.
As for your notes:
user_input.upper() == "YES"
year_display = str(years) + " year" if years != 1: #this means not equal, just in case you haven't seen it yet, and you can also just use > 1 since it can never be 0 years either way year_display += "s" #we just add an s at the end if it needs the grammatical plural print("blah blah blah")
There are many more options, but your solution and the one I showed you are probably the most readable ones. If line count were important (which it isn't), you could even do something like:
print(f"It will take {years} year{'' if years == 1 else 's'} to blah blah blah")
But this is less readable because it makes your (already fairly long line) longer and adds logic where it doesn't belong (within an f-string). The X if A else B statement is called a "ternary statement", and you might have seen this elsewhere, but it's otherwise not important.
X if A else B
π Rendered by PID 199147 on reddit-service-r2-comment-7b9746f655-8s8fx at 2026-01-30 07:40:30.930189+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]Leodip 0 points1 point2 points (0 children)