[Solved] How to put an input in a function


  1. You are never defining the function you’re trying to call.
  2. You’re printing from the function but never returning a value, thus your variable “a” will never get a value.

Take a look at this, hopefully you’ll see where you went wrong:

def odd(x):
    if int(x) % 2 == 0:
        return("this number is even")
    else:
        return("this number is odd")

x = input("Enter number")
print(odd(x))

Good luck! 🙂

To further answer your question “how to put an input in a function” (which was never actually done in the first place), you could instead do it like this which would give you the same result.

def odd():
    x = input("Enter number ") 
    if int(x) % 2 == 0:
        return("this number is even")
    else:
        return("this number is odd")

print(odd())

solved How to put an input in a function