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 trialEvan McPheron
4,273 Pointsuse .format() on the string "Treehouse loves {}" . put your name in the braces
I'm trying to add my name to the subject variable using .format() and I can get it to work in the preview but for some odd reason it's saying that I'm not doing it right. Can anyone tell me what is going on and why it won't take my code as correct? I'm assuming that I'm missing some small detail.
name = '''Evan'''
subject = '''Treehouse loves {}'''.format(name)
3 Answers
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Evan
The problem is you are using triple quotes on the string. The only time you use triple quotes is when you need a multi line string.
name = 'Evan'
subject = 'Treehouse loves {}'.format(name)
Evan McPheron
4,273 PointsI did that too. I entered it exactly like you put it there with only single quotes and for some odd reason it says I'm doing it wrong. When I look at the preview it's executing the code properly. Once I started digging I noticed other people having the same issue. I'm wondering if it's not recognizing my text for some odd reason.
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsThat's very strange, i run the same code and it works just fine.
Evan McPheron
4,273 PointsI changed browsers and it worked fine then. Maybe I was just using something outdated. Thanks for your help!