Code works, but an Oops! message still pops up


Practice Makes Perfect - Fun with Numbers is_even Lesson 15 2

The code below works and produces the correct result, but a message pops up saying e.g. "Oops, try again. is_even(7) returned True instead of the expected: False" I can't move on to the next lesson. Any suggestions?


print('Please enter a number: ')
x = int(input())

def is_even(number):
number = x
if number % 2 == 0:
return True
return False
if is_even(x) == True:
print('Thank you, ' + str(x) + ' is even.')
print('Thank you, ' + str(x) + ' is not even.')


That line can be removed. It is overwriting your parameter variable. It's important to note that the instructions don't ask us to get user input, so the SCT will not be expecting that part of the code. It will be testing with direct inputs in the call expressions.

Make your code as simple as possible to pass the lesson. Then you are free to experiment in the lesson IDE.


Thank you very much. Your suggestion worked and I appreciate the explanation that accompanied.