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 trialTrey Grider
265 PointsJust not to sure what i am doing wrong, dealing with placeholders in strings.
Any insight would be much appreciated.
name = "Trey"
"Treehouse loves {}" = subject
subject.format(name)
1 Answer
AJ Salmon
5,675 PointsHey 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
265 PointsTrey Grider
265 PointsGreat insight, thanks so much!
AJ Salmon
5,675 PointsAJ Salmon
5,675 PointsYou're very welcome!