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

Allison Liu
Allison Liu
66 Points

i need help how do i do this

help me plz

using_variables.py
favorite_color = "blue"

1 Answer

Rick Gleitz
Rick Gleitz
47,878 Points

That should be fine to pass the first task. I'm assuming you need help with the second. It's just a print() statement where you can take what was given at the top: The color [YOUR FAVORITE COLOR] is my favorite! put it in the parens of a print() statement and replace [YOUR FAVORITE COLOR] with the variable name and put the first and last parts inside the parens in quotation marks and separate the three parts with commas. Hope this helps!

Allison Liu
Allison Liu
66 Points

how the hell am I supposed to do that?

Rick Gleitz
Rick Gleitz
47,878 Points

OK, I'll break down what I said above with some visuals. Add a print statement: print()
Inside the parens put in the string: "The color [YOUR FAVORITE COLOR] is my favorite!" Replace [YOUR FAVORITE COLOR] with the favorite_color variable, so it looks like:
"The color ", favorite_color, " is my favorite!" This is formatted with a quote to close the first part of the string, and a comma and space to separate this part of the string from the variable name. After the variable is a comma, a space, another quote (to begin the last part of the string) and a space. So putting it all together you have:

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