Welcome to the Treehouse Community
Looking to learn something new?
Russell AlsonCourses Plus Student 1,297 Points
Even or Odd challenge
Could anyone give a explanation why this is wrong?
def even_odd(num): x = int(num) for n in x: if n % 2 == 0: return True else: return False
Chris FreemanTreehouse Moderator 67,986 Points
The error raised is because you can not iterate over an integer
x. The for loop is not needed. Change the
if statement to use
x instead of
Shreyas Papinwar2,371 Points
def even_odd(number): if number % 2 == 0: return True else: return False