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 trialStian Hølland
Courses Plus Student 238 PointsCant seem to get the correct answer even though I think I am right
The code to accept input for the favorite color has been provided for you. For this task, add a branch that checks if the favorite_color is equal to "blue". If it is indeed "blue" print out to the screen, "You must love the sky!"
branching.py favorite_color = input("What is your favorite color? ") if favorite_color == "blue": print("you must love the sky!")
favorite_color = input("What is your favorite color? ")
if favorite_color == "blue":
print("you must love the sky!")
5 Answers
Adam N
70,280 PointsYou should indent the body of an if statement, but not the if statement itself.
Let me know if this helps here
Jason Anders
Treehouse Moderator 145,860 PointsHi Stian,
Check your indents. Python is very indent specific.
The if
block should start at the same level as the input
line, and then the block for the if
should be indented by 4. Right now it looks like there are 2 spaces for the if
.
Otherwise, nice work! :)
Stian Hølland
Courses Plus Student 238 PointsThanks, got it now ;)
Hom Dahal
1,537 Pointsfavorite_color = input("What is your favorite color? ") if favorite_color == "blue": print("you must love the sky!")
Tafadzwa Charingana
440 PointsThe code to accept input for the favorite color has been provided for you. For this task, add a branch that checks if the favorite_color is equal to "blue". If it is indeed "blue" print out to the screen, "You must love the sky!"
Hom Dahal
1,537 PointsActually start if statement right below first statement, meaning no indentation in the second sentence and when you enter for third sentence it will automatically indent for third statement for print hope this helps