hi, im trying to learn python and this is giving me

>>> x=input("Enter a value: ")
if x % 2 ==0:
print ("even")
else:
print ("odd")

then when i execute:


Enter a number:

then i enter a number but it does not print even or odd. why?

You have to convert the string from the input to an integer.

x = int(input("Enter a value: "))

Remember you have to catch the exception that will be raised if the input is not a number.

I assume you are using the new Python3 version. The input() function replaces the old raw_input() function and returns a string. So follow vidaj's advice.

Works for me ...

x = int(input("Enter an integer value: "))
if x % 2 == 0:
    print("even")
else:
    print("odd")

Maybe your problem is that you are using the Python shell. Generally that it is only for testing one-liners. Write and run your programs from an IDE like IDLE (usually installed with your Python distribution), see:
http://www.daniweb.com/forums/post104834-1.html

This question has already been answered. Start a new discussion instead.