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 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,412 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.