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 trialMargaret Maginnis
199 Pointswhat what what am I doing wrong. I cannot format the next challenge
can someone show me exactly what I should be writing to be correct in formatting?
name = "Margaret"
subject = "Treehouse loves " + name
status_message = "Treehouse loves + { } "
"My { } is { }" .format ("name" , "Margaret")
print (status_message .format ( name, Margaret))
print (status_message)
4 Answers
Jennifer Nordell
Treehouse TeacherIt wants you to use string interpolation and assign the string to the variable subject. See my code for the correct formatting.
name = "Jane"
subject = "Treehouse loves {}".format(name)
Jennifer Nordell
Treehouse TeacherYour code in a project of your own should work. However, the challenge specifically asks you to take the formatted string (all of it) and assign it to a variable... not print it. That's why the challenge fails. If you do something the challenge doesn't specifically ask you to do , the code (even if functional) will likely fail the challenge as it can't properly identify the results. This is what you need.
name = "Ragnar"
subject = "Treehouse loves {}".format(name)
Andreas Ragnar Hansen
1,871 PointsThanks for clarifying...
Margaret Maginnis
199 PointsI'll try this-thanks Jennifer!
Andreas Ragnar Hansen
1,871 PointsWhy gives this code me an error message? Technically is should be right?
name = "Ragnar"
subject = "Treehouse loves {}"
print(subject.format(name))