mercredi 21 janvier 2015

Python If Statement definition error [duplicate]


This question already has an answer here:




I'm trying to test out if statements with the use of letters instead of numbers. I'm not sure what the error in my code is, can someone please help out



ppp=input('Enter a, or b. or exit to exit')

while ppp!='exit':

if ppp=='a' or ppp=='A':
print('You Picked A')
ppp=input('a,b, or c?: ')

elif ppp=='b' or ppp=='B':
print('You Picked B')
ppp==input('a,b, or c?: ')

else:
print ('please choose a, or b')


When running it, it prints "Enter a, or b. or exit to exit" but when entering anything whether a, A, b, B, exit, or any random word or letter or number I get



Traceback (most recent call last):
File "temp.py", line 1, in <module>
ppp=input('Enter a, or b. or exit to exit')
File "<string>", line 1, in <module>
NameError: name 'a' is not defined


Please someone tell me what's wrong with my code.


Aucun commentaire:

Enregistrer un commentaire