Newbie question about evaluating raw_input() responses

C. N. Desrosiers cndesrosiers at gmail.com
Wed May 22 02:23:15 EDT 2013


Hi,

I'm just starting out with Python and to practice I am trying to write a script that can have a simple conversation with the user.

When I run the below code, it always ends up printing response to "if age > 18:" -- even if I enter a value below 18.

Can anyone point me to what I am doing wrong?  Many thanks in advance.

age=raw_input('Enter your age: ')
if age > 18:
    print ('Wow, %s. You can buy cigarettes.' % age)
else:
    print ('You are a young grasshopper.')



More information about the Python-list mailing list