[Tutor] Extremely simple question
col speed
ajarncolin at gmail.com
Wed Jan 11 12:04:46 CET 2012
>>>>
>>>>> your_weight = int(raw_input("Please enter your weight: "))
>>>>> if your_weight < 0:
>>>>> print 'You're not Chris!'
>>>>> elif your_weight == 170:
>>>>> print 'You might be Chris! But...'
>>>>> your_height = int(raw_input("Please enter your height: "))
>>>>> if your_height < 180:
>>>>> print 'You're not Chris!
>>>>> elif your_height == 180:
>>>>> print 'You're Chris!'
>>>>> your_name = int(raw_input("What is your name? "))
>>>>> elif your_height > 180:
>>>>> print 'You're not Chris!"
>>>>> elif x > 170:
>>>>> print 'You're not Chris!'
>>>>
>>>>
>>>> When I open it, the program says I have a syntax error. Praytell, where
>>>> did
>>>> I go wrong?n
I'm a newbie, but I get "NameError" because 'x' is not defined.
Also "your_name = int(raw_input("What is your name? "))" will give this :
ValueError: invalid literal for int() with base 10: 'name'.
As you can't change a string to be an int.
I can't find a syntax error, but next time, please paste the whole
traceback as this helps people with less time than me to sort out
problems.
Good luck with Python
Col
More information about the Tutor
mailing list