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 trialDavid Hammer
1,972 PointsI dont get it
how do I add the variable to the string?
favorite_color = "green"
print("The color {} is my favorite!")
favorite_color.format(favorite_color)
2 Answers
John Lack-Wilson
8,181 PointsYou're pretty close here. An easier way to pass this challenge is to use python's string concatenation operator. Here's an example.
favorite_language = "Python"
print("My favourite programming language is " + favorite_language + "!")
The output of the above code would be: My favourite programming language is Python!
Jen Farrant
6,905 PointsThe other way is to use the curly braces - like you have done, but it is slightly wrong:
favorite_color = "green"
print("The color {} is my favorite!".format(favorite_color))