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

Trey Grider
Trey Grider
265 Points

Just not to sure what i am doing wrong, dealing with placeholders in strings.

Any insight would be much appreciated.

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

1 Answer

AJ Salmon
AJ Salmon
5,675 Points

Hey Trey,

Firstly, make sure that the variable name always goes on the left side of the equal sign -


subject = "Treehouse loves {}"

not

"Treehouse loves {}" = subject


With that out of the way, the challenge is asking you to assign the string "Treehouse loves {}".format(name) to the variable subject. Calling it like you did will perform the formatting, but it won't actually alter the string. Printing subject would still give you "Treehouse loves {}", which is not what this challenge is asking for. Hint: you will create the variable subject on the same line you format the string. Hope this helps, and happy coding :)

Trey Grider
Trey Grider
265 Points

Great insight, thanks so much!

AJ Salmon
AJ Salmon
5,675 Points

You're very welcome!