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 Create a Variable

the

using_variables.py
print("The color", favorite_color, = "is my favorite!")

2 Answers

diogorferreira
diogorferreira
19,363 Points

You're doing it right but just remove the = sign you're not setting a variable. :)

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

i had tried this too bit it says "Task #1

F.

FAIL: test_code_expectations (main.TestCreateAVariableCode)

Traceback (most recent call last): File "", line 18, in test_code_expectations AssertionError: '=' not found in 'print("The color", favorite_color, "is my favorite!")' : To assign your variable with a value make sure you use the equals sign.


Ran 2 tests in 0.000s

FAILED (failures=1) Task #2

F.

FAIL: test_code_expectations (main.TestCreateAVariableCode)

Traceback (most recent call last): File "", line 18, in test_code_expectations AssertionError: '=' not found in 'print("The color", favorite_color, "is my favorite!")' : To assign your variable with a value make sure you use the equals sign.


Ran 2 tests in 0.000s

FAILED (failures=1)

F

FAIL: test_code_expectations (main.TestPrintAVariableCode)

Traceback (most recent call last): File "", line 19, in test_code_expectations AssertionError: 1 not greater than or equal to 2 : Ensure you are reusing your variable favorite_color


Ran 1 test in 0.000s

FAILED (failures=1)"

diogorferreira
diogorferreira
19,363 Points

That's because you have to set a variable before to your favorite color. Otherwise python won't know what the variable holds. You can do this like so: favorite_color = 'put your favorite color in here'

Example:

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