Automate The Boring Stuff With Python, question.

Ok, and for the record, this might be some beginner oversight on my part.

It appears there are some small differences between what is on the website and in the book that I have. I'm doing the flow statemens and loop stuff right now. In the book the program for vampire.py is: if name == 'Alice': print('Hi, Alice.') elif age < 12: print('You are not Alice, kiddo.') elif age > 100: print('You are not Alice, grannie.') elif age > 2000: print('Unlike you, Alice is not an undead, immortal vampire.')

The website appears to have two different lines, one to define name = 'Dracula' age = 4000

Here is my code that I had to change around a bit to get to work. print('What is your name?')
name = input() if name == 'Alice': print('Hi, Alice.') print('What is your age?') age = int(input()) if age <int(12): print('You are not Alice, kiddo.') elif age == int(12): print('This is Alice.') else : print('You are too old.')

I had to use if for the age instead of elif, if I didnt and did it the way the code was in the book it would just default to the first print statment no matter what age I typed in when running it. Also, I had to condense age = int(input()) into one line to get it to respond to the age I typed instead of defaulting to the You are not Alice, kiddo' response. and I wasnt able to use several print statements with the age options unless I made the last just an else statement rather than another elif with the defined parameters

/r/learnpython Thread Parent