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

I feel like i am not getting the question. when i work out this equation in python, it works. but not on the test.

name = "kriss" subject = "treehouse loves {}" str.format(subject,name)

In the python workspace it comes out to 'treehouse loves kriss'

but the test is coming out incorrect...

strings.py
name = "kriss"
subject = str.format("Treehouse loves {} ",name)

1 Answer

There seem to be two different sets of code in your post, so I'm not sure which one is your most recent. To use format(), you just need to put it after a period that comes right after a string literal like so

'Here is some {}'.format(variable_you_want_to_put_in_senctence)

then you just put the variable inside the parenthesis. In this case it would be name. Here is the answer:

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