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 trialVictor A Hernandez
1,957 Pointselif. 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))
else:
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
Tiffany Greathead
6,613 PointsHi 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
Victor A Hernandez
1,957 PointsThank 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.
Victor A Hernandez
1,957 Pointselse: 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.
Tiffany Greathead
6,613 PointsNo problem! Glad it helped
Chris Freeman
Treehouse Moderator 68,457 PointsChris Freeman
Treehouse Moderator 68,457 PointsGood answer Tiffany! Thanks for helping out in the community forum. Comment moved to answer.
Tiffany Greathead
6,613 PointsTiffany Greathead
6,613 PointsThank you, Chris Freeman.
I'll be sure to post it in the right section next time :)