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
35,037 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
35,037 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!")