Q:

How to return an integer in a python function?

For example I am considering a very easy case. I want to write a function to check whether the given input number is even and return 2 if it is even and 1 if it is odd. I tried this:
a=int(input("Enter no. : "))
def isEven():

    if (a%2==0):
        return 2
    else:
        return 1

isEven()

But this is not returning anything. How to return 1 or 2 based on input? Thanks in advance for your time and help:)

A:

The function does return the number. You cannot see it because you didn't print it.
Besides, it's better to pass the number you want to check to the function as a parameter. The code should look somehow like this:
a = int(input("Enter no. : "))
def isEven(n):

    if (n % 2 == 0):
        return 2
    else:
        return 1

print(isEven(a))

