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 Python Basics Types and Branching Use an if

Cant 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!")

branching.py
favorite_color = input("What is your favorite color?  ")
  if favorite_color == "blue":
      print("you must love the sky!")

5 Answers

You should indent the body of an if statement, but not the if statement itself.

Let me know if this helps here

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi 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! :) :dizzy:

Thanks, got it now ;)

favorite_color = input("What is your favorite color? ") if favorite_color == "blue": print("you must love the sky!")

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!"

Actually 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