All right! Let’s get started.
I completed the exercise, but would like to understand it better by feeding a list into the function.
The code below works for one value. When a value is 40 it prints TRUE.
# z = [1, 2, 3] def is_even(x): if x % 2 == 0: return True else: return False print (is_even(40))
But I am not sure how to use a list. Please point me in the right direction.
I tried below code
z = [1, 2, 3] def is_even(x): if x % 2 == 0: return True else: return False print (is_even(z))
which gave me an error
Traceback (most recent call last): File "python", line 9, in <module> File "python", line 4, in is_even TypeError: unsupported operand type(s) for %: 'list' and 'int'
Not sure how to iterate over the list.