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

traolach trewhella
PLUS
traolach trewhella
Courses Plus Student 835 Points

can somone break this down for me. i seem to be missing the point

do i put the braces in the string im trying my best with this(:

strings.py
name = "trey"
subject = "treehouse loves {},format()"

3 Answers

Nathan Tallack
Nathan Tallack
22,160 Points

You were close. We are moving the .format outside of the quotes and we are popping the name variable as the parameter for the .format so that it puts that into the place of the {}'s.

Note also that the string starts with a capital 'T' for Treehouse rather than the lowercase you used. The workspace check cares about case inside of strings so take care to match what the instructions require.

name = "trey"
subject = "Treehouse loves {}".format(name)
Nathan Tallack
Nathan Tallack
22,160 Points

Works for me. Maybe reload the page in your browser. Sometimes your cache breaks the workspace challenges.

cant you also do

subject = "Treehouse loves swift \(name)"
Nathan Tallack
Nathan Tallack
22,160 Points

You could syntatically. But you should take care to do it the way they say in the challenge. They specifically ask for you to use .format, so they may be looking for you using that format.