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 trialDmitry Kozloff
1,371 PointsHow do I use format for subject variable
name = "Dmitry Kozloff" subject = "Treehouse loves {}" How to use .format to place name in {}
name = "Dmitry Kozloff"
subject = "Treehouse loves {}"
print(subject.format(name))
1 Answer
Krishna Pratap Chouhan
15,203 PointsBuddy, dont waste your time... check if it doesn't work try on your python console. If it(python console) gives error then you are missing some point. Don't completely trust the console/evaluation of treehouse.
What you are doing is:
name = "Dmitry Kozloff"
subject = "Treehouse loves {}"
print(subject.format(name))
which is perfectly correct and makes sense. But treehouse wants it a little differently.
name = "Dmitry Kozloff"
subject = "Treehouse loves {}".format(name)
same thing right? but this would pass their test and the previous wont.
I know... it sucks sometimes.
Dylan Davenport
Courses Plus Student 2,645 PointsDylan Davenport
Courses Plus Student 2,645 PointsI've had the same thing happen. The treehouse console wants it EXACTLY their way and their way only haha.