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

Nikita Khudyakov
Nikita Khudyakov
509 Points

Hey. Just checked my test in workspace and it works according to task requirement. Don't know what is wrong.

name = 'Nikita' subject = ('Treehouse loves {}') subject.format(name)

1 Answer

andren
andren
28,558 Points

The task requirements is that the subject variable is set equal to a string that is formatted with your name. In your code you set it to a string with a placeholder, and you format it on the third line but you don't do anything with that formatted string.

You are meant to use the format method directly on the string that you assign to subject on line 2 like this:

name = 'Nikita'
subject = 'Treehouse loves {}'.format(name)

That will place the properly formatted string into the subject variable which is what the challenge is looking for. You might also notice that I removed the parenthesis you had placed around the string on line 2, since they are in fact not necessary.