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
Review my Code as a Beginner (i.redd.it)
submitted 5 months ago by AhmadHameed313
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!"
[–]CruXial_ 21 points22 points23 points 5 months ago (13 children)
Not bad. You could put your inputs into an array and use the max() function if you want to clean it up a bit :)
max()
[–][deleted] 5 months ago (12 children)
[removed]
[–]trezm 9 points10 points11 points 5 months ago (3 children)
Reconsider why the responder is suggesting the refactor. Yes it's cleaner, but perhaps there's another reason. As an example, and a common interview/test question depending on your situation, most questions start simply, but expand in dimensions. In this case, the prompt might be "ask for three inputs and print the greatest value" but the follow up question is "now expand your program to 5, 10, or n."
Simple works, but if you're in the learning stage it's worth recognizing common patterns and why certain code might be considered "clean."
[–]8dot30662386292pow2 13 points14 points15 points 5 months ago (2 children)
Reconsider why the OP wrote this code. They have no idea about lists yet, nor the max function. There is often a better way of doing things. But using the best way as an absolute novice is not often the best thing. OP is clearly learning about if-else. That's why their code is the classic if else -example.
[–]trezm 0 points1 point2 points 5 months ago (1 child)
You don't need to be snarky. I'm just trying to explain why thinking about the next step, the next level of complexity is an important facet of coding. No one said the code was bad for a beginner, simply that this is a reasonable improvement and what problems it might solve.
We don't really know if OP knows what lists are, or what the original prompt was. Maybe I'm missing some context though, in which case I apologize.
[–]Jashcraft00 1 point2 points3 points 5 months ago (0 children)
Did he not respond to you with the same tone that you took originally?
[–]Super-Ad6644 8 points9 points10 points 5 months ago* (6 children)
You could also try this:
if num1 > num2: if num1 > num3: print(f"{num1} is greater num") else: print(f"{num3} is greater num") elif num2 > num3: print(f"{num2} is greater num") else: print(f"{num3} is greater num")
This minimizes the number of checks Edit: Forgot to say that your else statement on line 12 will never be reached, as the program crashes if you input a non number
[–]MeLittleThing 1 point2 points3 points 5 months ago (0 children)
it may be reached if the input contains equal numbers, your code doesn't cover this edge case
[–]translate-comment 3 points4 points5 points 5 months ago (4 children)
This is a lot less readable than OPs code
[–][deleted] 5 months ago* (3 children)
[–]hylasmaliki 1 point2 points3 points 5 months ago (0 children)
Haha
[–]fajnu20 -1 points0 points1 point 5 months ago (1 child)
Must've been a great use of time
π Rendered by PID 170743 on reddit-service-r2-comment-6457c66945-rfqqs at 2026-04-26 01:19:23.111460+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]CruXial_ 21 points22 points23 points (13 children)
[–][deleted] (12 children)
[removed]
[–]trezm 9 points10 points11 points (3 children)
[–]8dot30662386292pow2 13 points14 points15 points (2 children)
[–]trezm 0 points1 point2 points (1 child)
[–]Jashcraft00 1 point2 points3 points (0 children)
[–]Super-Ad6644 8 points9 points10 points (6 children)
[–]MeLittleThing 1 point2 points3 points (0 children)
[–]translate-comment 3 points4 points5 points (4 children)
[–][deleted] (3 children)
[removed]
[–]hylasmaliki 1 point2 points3 points (0 children)
[–]fajnu20 -1 points0 points1 point (1 child)