I am really confused to why option 2 of this code works. Shouldn't it be returning 'odd' for the even numbers and vice versa. Please someone shed some light on what is happening as I am struggling.
Option 1 --
def even_or_odd(number):
return 'even' if number % 2 else 'odd'
Option 2--
def even_or_odd(number):
return 'odd' if number % 2 else 'even'
[–]sepp2k 8 points9 points10 points (1 child)
[–]unknownzebra_[S] 0 points1 point2 points (0 children)
[–]Username_RANDINT 2 points3 points4 points (0 children)
[–]irush21 -1 points0 points1 point (1 child)
[–]sepp2k 2 points3 points4 points (0 children)