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

Linh Tran
Linh Tran
177 Points

how to use .format() to put name into the placeholder?

how to use .format() to put name into the placeholder?

strings.py
subject="Treehouse loves "
name="Linh"
print ("Treehouse loves {}",format("Linh"))

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

You're soooo close here! First, it doesn't want you to print that string. It wants it reassigned to subject. I'm quite sure you've gotten emails from Treehouse by now with the subject line: "Treehouse loves Linh", right? That's what we're going for here.

Secondly, before the format that should be a period not a comma. Third, we can use the name variable you set up earlier to put "Linh" into the brackets. Take a look:

subject = "Treehouse loves {}".format(name)

Our subject variable will now have a value of "Treehouse love Linh". Just like the emails you get from Treehouse. Hope this helps! :smiley:

Linh Tran
Linh Tran
177 Points

my code finally can run now. thanks a lot, Jennifer :)

Ah thanks so much. I was suck in this problem.