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 Meet Python Variables

Code Challenge! I cant pass the second task question.

favorite_color = "Purple"


Getting message: AssertionError: 'Purple' not found in 'favorite_color' : Make sure you print out 'The color Purple is my favorite!'

it will always an error because you never can do this print = (favorite_color) , add to your print statement equal signThe right way like print (favorite_color).

you code have to look like; favorite_color = "Purple" print(favorite_color)

3 Answers

Louise St. Germain
Louise St. Germain
19,424 Points

You have correctly assigned "Purple" to the variable favorite_color using the = sign.

However, print is a function, not a variable, so you put the parentheses right after it, with no = sign, like this:

favorite_color = "Purple"

Note also that the question is asking for you to put the whole sentence 'The color Purple is my favorite!', not just the color by itself. You have the right idea with being able to print the contents of the variable ( = "Purple"), but you also need to put the rest of the sentence around it, like this:

favorite_color = "Purple"
print("The color", favorite_color, "is my favorite!")

This will print "The color ", and then the value of the variable favorite_color, which is "Purple", and then will print " is my favorite!". If you review the video, you will see that Craig does something similar when he customizes a printed message with his first_name variable. Hope this helps!

Thanks Louise. Your answer is correct.

Thanks Louise for the correct answer.