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
How do I ask to check if someone likes blue?
What if statement do I use?
favorite_color = input("What is your favorite color? ") favorite_color == "blue" Print("You must love the sky")
Cooper Runstein11,849 Points
You need to test if favorite_color is blue:
if favorite_color == 'blue': print("You must love the sky")
You would use what's called an IF conditional statement. In essence, it works just like in the English language. Eg: "If they have cakes at the store, I will get two." The if statement works when the condition given to it is true.
In your case, you would use the condition to see if the input variable is the same as the string "blue".
favorite_food = input ("what is your favorite food?") favorite_food = "pizza" if favorite_food == "pizza" print("You must love the big jay pizzeria down the street.")
Remember, you're using a two equal signs (== ). The two equal signs checks if the two things beside it are equal. The one equal sign (=) just assigns the value on the right to the variable on the left (a=10).