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
925 prod
421 PointsBranching Quiz
This is the question that I am stuck on: 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!"
This is my code: favorite_color = input("What is your favorite color? ") favorite_color = "blue" if favorite_color == "blue" print("You must love the sky!")
Can someone please clarify..
1 Answer
ursaminor
11,271 PointsYou need to delete favorite_color = "blue". favorite_color will be set by the user since you're asking for their input, so you should not set it inside the code. Also, if statement requires a colon at the end. It should like this:
favorite_color = input("What is your favorite color? ")
if favorite_color == "blue":
print("You must love the sky!")
In the future, please put your code in a code block like I've done. It's really hard to read code not in a code block and we can't tell if you've made indentation errors. A code block is surrounded by 3 back ticks -- they look like single quotes but point the other way, usually below the esc key. Put ```python to get the syntax colors. Refer to the Markdown Cheatsheet below the comment box for help.