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 trialFrank Gomez
2,127 Pointswrite out to the screen The color [YOUR FAVORITE COLOR] is my favorite! Where [YOUR FAVORITE COLOR] is using the var
What am I doing wrong?
favorite_color = ("blue")
print('The color favorite_color is my favorite!')
2 Answers
Erik Quiroga
3,474 PointsHey Frank,
You are halfway correct! But when naming variables, in this case:
# Remove the brackets and surround your value in either single or double quotes.
favorite_color = ("blue")
# Since the value "blue" is stored in variable favorite_color, it needs to be concatenated to the string using the plus sign (+) and a quote (") for spacing.
# Example:
car = "lamborgini"
print("In the future, I wish to have a "+car+" as my dream sportscar!")
# If you want to put your variable at the begginning of a string:
print(car+ " is the car I want!")
# At the end of a string:
print("My favorite sportscar is the " +car)
# Notice we need a puncutation, so:
print("My favorite sportscar is the " +car+ "!")
Hope this helps, if not let me know.
SHIVA KUMAR CHANDA
111 Pointsfavorite_color = "blue" print('The color is my favorite!')
jeremiah warren
Courses Plus Student 718 Pointsjeremiah warren
Courses Plus Student 718 Pointshey can you explain why, because the video i watched never said to use the + it said to use commas and it never explained how to use it in the middle of a string! the only example i got was using it at the beginning.