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 trialtylerpostuma2
5,175 PointsI'm not sure why this isn't working.
The question says to add the .format() function again to the subject variable, am I missing something?
name = "Tyler"
subject = "Treehouse lives {}"
subject.format(name)
3 Answers
Cindy Lea
Courses Plus Student 6,497 PointsPart 1: name = "Godzilla" subject = "Treehouse loves {}" subject.format(name)
Part 2: name = "Tyler" subject = "Treehouse loves {}".format(name)
Russell Sawyer
Front End Web Development Techdegree Student 15,705 PointsHi Tyler,
In real life coding speaking mistakes in a string are no problem and won't affect your code one way or another. But for these challenges spelling mistakes can be very frustrating.
I've worked and reworked my code on here only to find I had it right the first time but just had a spelling mistake.
Your code is correct. You just have a spelling mistake.
Your string should read "Treehouse loves {}." not lives.
tylerpostuma2
5,175 PointsHey Russell, for some reason, it still isn't working with the corrected spelling error. When I run the code through the treehouse editor I get this error:
Be sure to use the {}
placeholder and the .format()
method.
Not sure if it's a bug, or if I just don't have the right code! Thanks!
Russell Sawyer
Front End Web Development Techdegree Student 15,705 PointsThe way format works is you need to include what you want to add in the parentheses of the format that you want inside the {} in the string. The more {} you have in the string the more arguments you need to add to your format().
In this case you want to put your name inside the {} so you need to put either the string 'Tyler' or a variable assigned the name 'Tyler' in the parentheses of the format()
The challenge also stated to create a variable named subject to hold the string.
name = "Tyler"
subject = "Treehouse loves {}".format(name)
tylerpostuma2
5,175 PointsIt worked! Thanks Russell!