Why is this code wrong?

  • Write a function called is_it_five that takes a single number as its input. If the number is 5, then the function will return True . If the number is not 5, then the function should return None .
x = int(input())

def is_it_five():

    if x == 5:
        return(True)

    else:
        return None  

Your function is not taking anything as input. The only place you are taking user input is outside the function named is_it_five.

1 Like

@helpmeplease
No need to use parenthesis in the return statement.
As Randell says, you need to get the variable ‘x’ into your function to test the value. Right now the variable is just on the outside looking in.

x = int(input())

def is_it_five(x): #this X was missing here

    if x == 5:
        return(True)

    else:
        return None

#Calling function
is_it_Five(x)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.