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

String Concatenation - lumberjack.py

Hello,

I'm having problems with lumberjack.py (https://teamtreehouse.com/library/python-basics/ins-outs/string-concatenation)

The console says there are syntax errors

Here's my code:

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

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

4 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Ah. You're still in the Python shell. You need to exit() out of there before you run your script with python.

You need to concatenate the end of " sleeps all night and " and name.

name + " sleeps all night and " + name + "sleeps all day"

Still not working :(

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

if name == "Kenneth":
    print(name + "is a lumberjack and he's OK")
else:
    print(name + "sleeps all night and " + name + "sleeps all day")
Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Can you tell me more about how it's not working? You're using the Workspaces console and not your local machine, yes?

Yes, Kenneth. Here is a print: http://imgur.com/dXhTKil

The same happens when I use .format() http://imgur.com/EBGzwx9

I think you need to add spaces before "is" and both "sleeps"