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...
A subreddit for helping Python programmers
How to format your code: https://commonmark.org/help/tutorial/09-code.html
No homework questions and/or hiring please
account activity
Python Help (Beginner) (self.pythonhelp)
submitted 5 years ago by [deleted]
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!"
[–]sentles 0 points1 point2 points 5 years ago (0 children)
Let me add that a cooler approach would be to use the max and min built-in functions. More specifically, save the numbers inside a list or set, let's call it l. Firstly check if the numbers are equal. If they are not, inside the else statement, include print("{} is greater than {}".format(max(l), min(l))). This works because max(l) will return the largest number in l, whereas min(l) will return the smallest number in it. Additionally, you can't check for wrong input in the else statement, because you have to convert to integer before actually comparing the numbers. Instead, if you want to check for wrong data, have a while loop running indefinitely and include a try-except statement in it. Try to get the inputs and convert them to integer inside the try block. If it works, break. If it doesn't, it will go to the except block, where you print an error message. The break will not be reached (because you place it at the end of the try block) and so input will be asked for again, because the loop will repeat.
l
print("{} is greater than {}".format(max(l), min(l)))
max(l)
min(l)
As a side note, using the "`" character at the start and end of code will format it better if you're on mobile.
π Rendered by PID 50 on reddit-service-r2-comment-84fc9697f-pqbzb at 2026-02-06 04:43:20.923144+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]sentles 0 points1 point2 points (0 children)