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

adam n
adam n
57,283 Points

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 144,854 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!")

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

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