Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (Retired) Ins & Outs String Concatenation

SyntaxError: invalid syntax

i tried this code

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

if name == "aziz": print(name + "is Amazing !!") else: print(name + "is not as Amazing")

but it gives me this error

File "lumperjack.py", line 5
else:
^
SyntaxError: invalid syntax

1 Answer

Sage Elliott
Sage Elliott
30,003 Points

Hello! Your code is almost correct. I think what's happening is that your indentation is incorrect which will cause python to throw you an error. If you format your code like this it should work!

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

if name == "aziz":
  print(name + "is Amazing !!") 
else: 
  print(name + "is not as Amazing")

Note that you may want to add a space after the name in the output. One way of doing this would be something like this:

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

if name == "aziz":
  print(name + " " + "is Amazing !!") 
else: 
  print(name + " " + "is not as Amazing")

Thanks very much for your help ;)