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

Harsh Kumar Woike
Harsh Kumar Woike
204 Points

problem

name = input("what is your name? ")

if name == "harsh": print(name + " is a lumberjack") else: print(name + " is also a lumberjack")

the above written code is not compiling. it is showing syntax error in "else" line 5

1 Answer

Guillaume Maka
PLUS
Guillaume Maka
Courses Plus Student 10,224 Points

Try

name = input("what is your name? ")

if name == "harsh": 
  print(name + " is a lumberjack") 
else: 
  print(name + " is also a lumberjack")
Harsh Kumar Woike
Harsh Kumar Woike
204 Points

i did exactly that. when i posted my question the codes came in the same lines. but in the workspace i did exactly what you have suggested. this is the snapshot of my code. please have a look. https://w.trhou.se/44jrs731sw

Guillaume Maka
Guillaume Maka
Courses Plus Student 10,224 Points

The first print in the if statement is not correctly indented

code