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
Krisna Best
3,908 Pointsusing + sign with .format
The following code has been presented as a solution at this step but it has not worked for me.
name = "Krisna" subject = "Treehouse loves {}".format(name)
I get the error: You need to use a + to combine the string and name.
The video covered using combining strings and .format but not using + with .format.
2 Answers
Bob Buethe
3,276 PointsJust to add to Steven's answer: You said "The video covered using combining strings and .format but not using + with .format."
You don't need to use + with .format to combine strings. You use either + or .format, not both. In this case, the exercise is asking you to use +.
Steven Parker
243,318 Points
You would not use + with format. But you could use + instead of format.
You didn't include a link to the challenge, but based on the error message it appears that they want you to combine the strings using concatenation, which would involved the + operator. You would not use format or include a {} placeholder in the literal string.
Your solution using format does indeed accomplish the same result, but not in the way the challenge is expecting.
Krisna Best
3,908 PointsHey thanks for the assistance; this is helpful. I'll give the challenge another try and let you know if I run into problems.
Krisna Best
3,908 PointsKrisna Best
3,908 PointsThanks for that clarification, Bob. Much appreciated. :)