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 trialAbdallah Abdallah
215 Pointsformatting function
OK, so now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the variable subject again.
name = "Hey, all practice is good practive, right {}?"
subject = "Treehouse loves {}"
print(subject.format(name))
2 Answers
Steven Parker
231,248 PointsIt looks like you printed the result instead of assigning it.
The challenge asks you to "Assign this to the variable subject again." Be sure to assign the formatted string to the variable instead of printing it out!
Try adding the .format function directly to the string on line 2, so the result will get assigned at the same time.
Abdallah Abdallah
215 PointsOh my god so close. I didn't realise you can put the format function after the string like that. I thought you would have to print and add format function on there. Thanks a a lot!
Abdallah Abdallah
215 PointsAbdallah Abdallah
215 Pointsso i should just leave it as subject = "Treehouse loves {} "? it doesnt work
Steven Parker
231,248 PointsSteven Parker
231,248 PointsNo, you still need to use .format on that string.
Abdallah Abdallah
215 PointsAbdallah Abdallah
215 PointsI am still quiet unsure how I would solve it. Could you help little bit more?
Steven Parker
231,248 PointsSteven Parker
231,248 PointsI don't normally give spoilers, but you are already so close...
subject = "Treehouse loves {}".format(name)
Notice how this formats the string and assigns it to the variable.