Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,623 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