i am new to python and running into something super silly. While trying to run an elif statement i am getting some errors. not sure what is it that I am doing wrong.
if name == 'Alice':
print('Hi Alice!)
elif age < 12:
print('You are not Alice, kiddo.')
When i run this in terminal I get the error.
NameError: name 'Alice' is not defined
I know that I can define name at the top on the lines
name = input('What is your name: ')
So that it will ask me for the name and it is defined as well.
But I enter the name != Alice say Alan. It throws this error
NameError: name 'age' is not defined
I want the elif clause to execute immeditely if age < 12 is True and name == 'Alice' is False. Not sure where am i going wrong.
Aucun commentaire:
Enregistrer un commentaire