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

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 ;)