Python problem


#1

Hey guys I just started learning some python, here is some problem that I encountered from the example of the book

if name == 'Alice':
print('Hi, Alice')
elif age<12:
print('You are not Alice, kiddo.')
elif age>2000:
print('Unline you, Alice is not an undead, immortal vampire.')
elif age> 100:
print('You are not Alice, grannie.')

The result:

Traceback (most recent call last):
File "C:/Users/User/OneDrive/Documents/Python/vampire.py", line 1, in
if name == 'Alice':
NameError: name 'name' is not defined

Above was the exact example that I used from the book. I really don't know what I did wrong, I tried to place the input for both variable 'name' and 'age' but received the syntax error message instead,

Looking forward to any reply. Thanks!

Replace this line with your code.


#2

Hi try to add that on top of your code

name = input("pust yor name");
age = input("what you age");
age = int(age)

the input makes the number you type a string so I add int() to convert the age from string to integer

you read more here about int()
https://docs.python.org/2/library/functions.html#int


#3

Python doesn't need semicolons...