Where's my mistake here?

I’m practicing and trying to make a program that tells you how many years it is until your 100. It works perfectly when line 1 is raw_input("What’s your name? "), but python 3.0 only has input so I was trying to use that. I’ve also tried using name = input("what’s your name? ") and converting it to a string after but I still get the same error. Any Idea what I’m doing incorrect?

Error I get is:
What’s your name? garrett
Traceback (most recent call last):
File “python”, line 1, in
File “”, line 1, in
NameError: name ‘garrett’ is not defined

name = str(input("What's your name? "))
age = int(input("What's your age? "))
years = 100 - age
printNum = int(input("How many times do you want to print it? "))

def timesPrint(printNum):
    while printNum > 0:
        print "I see that you're " + str(age) + ". That means you'll be 100 in " + str(years) + " years!"
        printNum -= 1
        
timesPrint(printNum)

Hi I run it here
repl.it

and it work if you put () around the string of the print

print "I see that you're " + str(age) + ". That means you'll be 100 in " + str(years) + " years!"

Woah, thanks for showing me that site :smiley:

Maybe it’s just something with CodeAcademy using pre 3.0 stuff

1 Like

@ghughes13
Here a discussion/opinion
http://stackoverflow.com/questions/4960208/python-2-7-getting-user-input-and-manipulating-as-string-without-quotations

2 Likes