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 trialTito Das
198 PointsWhat is wrong here -- >> name = "Tito" >> str1 = "Treehouse loves {}" >> subject = str1.format(name)
What is wrong here --
name = "Tito" str1 = "Treehouse loves {}" subject = str1.format(name)
name = "Tito"
str1 = "Treehouse loves {}"
subject = str1.format(name)
2 Answers
andren
28,558 PointsThere is nothing inherently wrong with your code. But the challenge checker for these tasks can be pretty picky. Even if the result is correct if you did not achieve the result in the way that is expected your code will often be marked as wrong.
The problem in this specific instance is that you create the str1 variable and assign the message to it, you can complete this challenge without doing that. You can simply use format directly on the string as you assign it to the subject variable like this:
name = "Tito"
subject = "Treehouse loves {}".format(name)
That is the way the challenge checker expects you to solve the problem, and as such is the only solution it will accept.
Tito Das
198 PointsThx. Just did.
Tito Das
198 PointsTito Das
198 PointsThanks andren. Yes, I just figured that. Keep tweaking till challenge checker is happy. Else, once u r happy with the results on ur terminal, proceed to the next lesson (keeping challenge checker unhappy) in the best interest of time..:-))
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsCan you give andren a "Best Answer" so this question will appear solved in the Community? Thx, alex