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 trialAddison DeViese
587 PointsI can't get the hang of .format method mind helping me
ive been trying to get the hang of this and have put it in ever way i can think too but the times were it looks right it says line one isn't running. and the way its shown currently is the only way i can get it without it saying line one has stopped but its in the wrong form.
name = "name"
subject = "treehouse loves {}" .format(name)
1 Answer
andren
28,558 PointsThe reason why you are not able to pass the challenge is not actually due to an issue with your code, but due to the fact that the challenge checker is often very picky and exact about what it expects your code to output and look like.
There are two issue in particular in your code that trips the challenge checker up:
It asks you to format this exact string "Treehouse loves {}" notice that the T in treehouse is capitalized in this string, in your string it is not, that difference is enough to make the challenge checker fail you.
The challenge checker expects the .format call to come directly after the string, in your code there is a space between the string and the call to the .format method, that is also enough to make it mark your code as wrong.
Fixing those two issues results in this code:
name = "name"
subject = "Treehouse loves {}".format(name)
Which will pass the challenge.