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

Python Python Basics (2015) Python Data Types String Formatting

Gary Gibson
Gary Gibson
5,011 Points

This question is unclear to me and I have no idea what I'm supposed to type.

"OK, so now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the variable subject again."

4 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

To "use format on the string" means to use the .format() method, The .format() method takes arguments which will be used to fill in placeholder "fields" in the string. The argument count and the placeholder count must match. In this example, the name variable will be the argument:

# Task 2 of 2

# OK, so now use '.format()' on the string "Treehouse loves {}" to put
# your name into the placeholder. Assign this to the variable 'subject' again.
subject = "Treehouse loves {}".format(name)
Gary Gibson
Gary Gibson
5,011 Points

Hi! After playing around with it for a little while, I FINALLY got it. That's what I came up with, too. Got through the challenge. Thank you for getting back to me.

Petrius Balbinot
Petrius Balbinot
1,805 Points

None of the answers seem to help. Huh Teamtreehouse isn't supposed to help posting answers to students?

OK, now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the variable subject (so start with subject =).