Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (Retired) Ins & Outs String Concatenation

Vrund Patel
Vrund Patel
11,994 Points

Running error

name = input("What's your name? ")

if name == "Vrund":
  print(name +  "is a lumberjack and he's OK!")
else:
  print( name + "sleeps all night and works all day!")  

I try to run this code in iTerm and it gives me error:

What's your name? Vrund
Traceback (most recent call last):
  File "hello.py", line 1, in <module>
    name = input("What's your name? ")
  File "<string>", line 1, in <module>
NameError: name 'Vrund' is not defined
Vrunds-MacBook-Pro:desktop vrundpatel$

2 Answers

I am thinking it is a space relation. What happens when you try with no empty lines? =) ... name = input("What's your name? ") if name == "Vrund": print(name + "is a lumberjack and he's OK!") else: print( name + "sleeps all night and works all day!")

Vrund Patel
Vrund Patel
11,994 Points

Nope, gives the same error.

Where are you putting the {}? =)