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 trialjames tyson
1,302 Pointsi am really confused on how i am suppost to out the format i am useing it in this sense subject.format("Treehouse loves
subject.format("Treehouse loves {}",(subject = name))
name = "deja vu, huh?"
subject.format("Treehouse loves {}",(subject = name))
1 Answer
Chris Freeman
Treehouse Moderator 68,457 PointsYou've got all the parts, but in a jumbled order. Let's break down this task:
OK, now use .format() on the string "Treehouse loves {}"....
.format()
is a string method, which means it needs to operate directly on a string or a variable pointing to a string:
"Treehouse loves {}".format()
to put your name into the placeholder.
The placeholder, also called a replacement field, is marked by the curly brackets {}. The arguments to the format
method are used, in order, to fill in each replacement field. If more than one, the arguments are separated by a comma.
"Treehouse loves {}".format(name)
Assign this to the variable subject (so start with subject =).
The format
method takes a string and returns a new string. To save this new string, it needs to be assigned to a variable. Do this by prepending the code statement above with subject =.
Post back if you need more help. Good luck!!