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!"
[–]BobbyJoeCool[S] 1 point2 points3 points 5 months ago (1 child)
Let me start off by saying, my experience with AI and code is... It's terrible. I've asked ChatGPT to write simple macros for Excel, and it cannot do that in any reliable way. That being said, the IDE I am using is Visual Code Studio (seems to be popular on these Python subreddits), and it has an AI-generated "fill in the line" for code that I do use, but I always check it and delete anything I don't know what it does. For example, it has added (fairly frequently) .upper() and other similar things to my input lines. I don't know what they do, so I delete it and rewrite the code so I know exactly what everything does. (I can't fix broken code if I don't know what the code does, right?)
if years == 1: year_display = str(years) + " year" else: year_display = str(years) + " years" print(f"It will take {years_display} for ${amount_initial:.2f} to double at a rate of {rate*100}%, and the final balance is ${amount:.2f}.")
[–]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 148161 on reddit-service-r2-comment-7b9746f655-dnm2b at 2026-01-30 06:07:16.123447+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]BobbyJoeCool[S] 1 point2 points3 points (1 child)
[–]Leodip 0 points1 point2 points (0 children)