Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

john herron
2,485 PointsIm on the .format() code challenge on python and Im completely lost on what to do
name = "john" subject = "treehouse loves {}" .format("john")
can anyone point out what I'm doing wrong?
name = "john"
subject = "treehouse loves {}"
subject.format("john")
2 Answers

Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi John so for this challenge, the marker is expecting a variable name to be passed to the format method. The way you have written the code, it makes the variable 'name' redundant. When i say redundant i mean you assigned your name to the variable 'name' but then passed a static string to the format method.
so if you pass the variable name to the format method the code would pass.
name = "john"
subject = "treehouse loves {}"
subject.format(name)

Jason Anders
Treehouse Moderator 145,624 PointsHey John,
You're on the right track. There are just a couple of things.
When you use the
format()
method, it has to be used directly on the string being formatted. So, you can't use a second declaration of the variable.You will want to pass in the variable
name
into the format method and not a hard coded stringFinally, and this one is just because the code checker for the challenges are very picky and specific, "Treehouse loves..." needs a capital "T".
name = "john"
subject = "Treehouse loves {}".format(name)
Hope this helps. Keep Coding! :)