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!

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

I keep re-watching the video, not sure what i am missing.


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

1 Answer

Unfortunately, Python doesn't support this syntax:

print("You must love the sky!")
if favorite_color = "blue"

if statements in Python follow the following form:

if <condition>:

where <condition> is the condition (in this code challenge, whether or not favorite_color is "blue"), and <body> is the code that is executed if the condition is met. (The body is printing "You must love the sky" onto the screen.)

Also note that you must use == instead of = to test equality. = is reserved for assignment, so you must use ==

Put together the pieces, and you should see...

if favorite_color == 'blue':
    print('You must love the sky!')