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 trialRabbie Wordie
1,441 PointsCode won't finish running the last line. And when I run with different name it runs the same.
first_name = input("What is your first name? ") print("Hello,", first_name) if first_name == "Rob": print(first_name, "is learning python") print("Have a great day {}!".format(first_name))
CONSOLE READS: python hello.py What is your first name? Rob Hello, Rob Rob is learning Python
python hello.py What is your first name? Kenneth Hello, Rob Kenneth is learning Python
CONSOLE SHOULD READ: python hello.py What is your first name? Rob Hello, Rob Rob is learning Python Have a great day Rob!
python hello.py What is your first name? Kenneth Hello, Kenneth Have a great day Kenneth!
What am I doing wrong?
2 Answers
Rick Gleitz
47,876 PointsI can't see how you've indented your print statements with what you posted, but to make the code do as on the video, you need to indent the print statement under the if statement, i.e. print(first_name, "is learning python"). The next print statement, i.e. print("Have a great day {}!".format(first_name)) is not indented (it runs outside of the if statement).
Hope this helps!
Rick Gleitz
47,876 PointsThat's OK. A very common problem!
Rabbie Wordie
1,441 PointsRabbie Wordie
1,441 PointsIndentation used: (Hopefully you can see it.) Periods used as place holder for indentation.
first_name = input("what is your first name? ")
print("Hello,", first_name)
if first_name == "Rob":
....print(first_name, "is learning Python")
print("Have a great day {}!".format(first_name))
Rabbie Wordie
1,441 PointsRabbie Wordie
1,441 PointsNvm... I just forgot to save. lol Sorry to waste your time. I appreciate your help.