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

Elif Syntax Error

Hi, When I input elif first_name == "Maximiliane": for the Elif exercise I'm getting a Syntax error in the Console. Can someone point me to what I'm doing wrong? Thanks!

4 Answers

first_name = input("what is your first name? ")
print ("Hello,", first_name)

if first_name == "Craig":
    print (first_name,"is learning python")
elif first_name == "Maximiliane":
    print(first_name, "is learning with fellow students in the Community! Me too!")
else:
    print("You should totally learn Python, {}!".format(first_name))
    print("Have a great day {}!".format(first_name))

I think the issue may have been in your formatting - I just ran the code after laying it out like above and it worked fine.

Make sure each new command is on a new line, and each indent is 4 spaces.

I hope this can help a bit!

Thanks, Scott! I have a feeling I did something to my console? I'm even getting a Syntax error when I type python hello.py or try to clear the screen. Sorry for the newbie questions, I'm just starting out.

It does sound like something in the console there - I'm not very fluent in console commands though, so I don't think I can help out there!

Never be sorry for asking questions - as cheesy as it sounds you'll never learn if you don't ask!

Would you be able to post your full code for us to look at?

Hi Scott, Here's the full code:

first_name = input("what is your first name? ") print ("Hello,", first_name) if first_name == "Craig": print (first_name,"is learning python") elif first_name == "Maximiliane": print(first_name, "is learning with fellow students in the Community! Me too!") else: print("You should totally learn Python, {}!".format(first_name)) print("Have a great day {}!".format(first_name))

Hi Scott, I found an answer to the issue! I had to exit the RFL to use the clear command so I typed quit() and then used the clear command. Clear is the command for the shell, not the RFL of python per the explanation I was given. Thanks for the support on this one and have a great day!