See How do I format code in my posts?
As for your code, good job getting the result you were after. You may want to consider a few things.
First, how can you DRY your code? (Don’t Repeat Yourself) You call the .max()
method twice. Is there a way to only call it once?
Second, do you need the elif
statement? When there are only 2 options, and the first condition isn’t met, we can simply execute the second option without testing the only other possible condition. For example:
def odd_or_even(num):
if num % 2 == 0:
return "Even"
return "Odd" # Default return if the number isn't even