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 trialKevin Koch
Full Stack JavaScript Techdegree Student 3,767 Pointselif
why is my code not working
first_name = input("What is your name")
print("Hello,", first_name)
if first_name == "mimi":
print(first_name, "is learning python")
elif first_name == "wale":
print(first_name, "is learning with a fellow")
else:
age =input("How old are you")
print("You should totaly learn python, {}!".format(first_name))
print("have a good day{}".format(first_name))
3 Answers
Ryan Markey
Front End Web Development Techdegree Student 12,565 PointsYour code works perfectly Kevin, the issue you are having is indentation and formatting.
You have:
if first_name == "mimi":
print(first_name, "is learning python")
elif first_name == "wale":
print(first_name, "is learning with a fellow")
When it should be:
if first_name == "mimi":
print(first_name, "is learning python")
elif first_name == "wale":
print(first_name, "is learning with a fellow")
Remember that python uses indentation and spaces in place of opening and closing curly braces '{ }', code must be properly formatted to work as intended.
Try pasting this inside your workspace and try it out.
first_name = input("What is your name? ")
print("Hello,", first_name)
if first_name == "mimi":
print(first_name, "is learning python")
elif first_name == "wale":
print(first_name, "is learning with a fellow")
else:
age =input("How old are you")
print("You should totaly learn python, {}!".format(first_name))
print("have a good day{} ".format(first_name))
Mark Sebeck
Treehouse Moderator 38,297 PointsI think it might just be formatting. Your if, elif and else need to line up. The prints need to not be indented or will only run if the else clause is executed. Unless the last prints are only suppose to print if the else is run then leave them indented. Let me know if you still need help.
first_name = input("What is your name")
print("Hello,", first_name)
if first_name == "mimi":
print(first_name, "is learning python")
elif first_name == "wale":
print(first_name, "is learning with a fellow")
else:
age =input("How old are you")
print("You should totaly learn python, {}!".format(first_name))
print("have a good day{}".format(first_name))
ronny nguyen
147 Pointsprint("Hello,", first_name) It should be print("Hello", first_name) Yo need to remove ,
ronny nguyen
147 Pointsfirst_name = input("What is your name") print("Hello", first_name) if first_name == "mimi": print(first_name, "is learning python") elif first_name == "wale": print(first_name, "is learning with a fellow") else: age =input("How old are you")
print("You should totaly learn python, {}!".format(first_name)) print("have a good day{}".format(first_name))