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

David Albers
David Albers
8,895 Points

Issues with the String Formatting challenge in the python basics course.

I have been doing the challenge at this location:

https://teamtreehouse.com/library/python-basics/python-data-types/string-formatting

Using the code that will be attached.

I have checked the code so many times that I have lost count and it looks exactly like what the instructor used in the training video. I have even used the workspaces console to run the code and it works just fine. However, every time I have the challenge check my code it gives me an error message

Bummer! Be sure to use the {} placeholder and the .format() method.

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

2 Answers

try subject = "Treehouse Love {}".format(name)

David Albers
David Albers
8,895 Points

Thank you so Much! So I am assuming, I could only right it the way I did, if I were using it in something like the print function, which is why it worked on the console correctly?

I think you use the .format() usually in the same line with {}.

It is like saying I want to fill {} with .format(you name what you want to fill it with)