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

Kennedy Otwenyo
Kennedy Otwenyo
785 Points

Hi, please help me in understanding the question because I still get the wrong answer:

Q: OK, now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the variable subject (so start with subject =). A:subject=('Treehouse loves{}'.format(' Ken'))

strings.py
subject=('Treehouse loves{}'.format(' Ken'))

3 Answers

Also, you are missing a space between the {} and the 'Treehouse loves' part. The string should look like this: 'Treehouse loves {}'

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

That too. However, it is "covered" by the preceding space in the format argument.

Oh... :laughing:

Another note to Kennedy Otwenyo: You should be formatting in the name variable. The entire purpose of variables is to store information, and you can use the variable's name (in this case name) to receive the value of that variable.

Maybe it isn't required for the challenge, but it is recommended :smiley:

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

The challenge asked for the variable "name". You have used "subject".

Additionally, while this will pass, the outermost parens are not needed surrounding the string format.

Kennedy Otwenyo
Kennedy Otwenyo
785 Points

Thank you guys, I sorted out the spacing before the '{}' and it ran successfully but the other insights are highly valuable too.