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 Types and Branching Comparisons

elif. What I made wrong with these?. My code does not run.I receive a message: Invalid sintax in line 8.

first_name = input ("What is your first name?")
print ("Hello,", first_name)
if first_name =="Craig":
    print (first_name, "is learning Python")
    print ("Have a great day {}!" .format (first_name))
    print ("You should totally learn Python, {}!" .format (first_name))
elif first_name == "Maximiliano":
    print (first_name, "is learning with fellow students in 

[MOD:: added ```python formatting -cf]

3 Answers

Hi Victor,

Your code looks good, you're on the right track. The last line has an elif statement after the else statement, which may be causing your error. Try moving the

elif first_name == "Maximiliano": 
  print (first_name, "is learning with fellow students in")

above the else statement.

Else statements always come after if and elif statements, they tell the program that if none of the above statements apply, do this. Also, the last line of code is incomplete. It needs to have ending quotation marks and parentheses, unless that part got cut off by accident. Hope this helps

Chris Freeman
Chris Freeman
Treehouse Moderator 68,064 Points

Good answer Tiffany! Thanks for helping out in the community forum. Comment moved to answer.

Thank you, Chris Freeman.

I'll be sure to post it in the right section next time :)

Thank you Tiffany, I'll do the correction and I'll let you know what happens. The last part of my code was cut by error.

else: print ("You should totally learn Python, {}!" .format (first_name)) else: print ("You should totally learn Python, {}!" .format (first_name)) I made the change , and my code worked. Thank you again Tiffany.

No problem! Glad it helped