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 trialRakshit H Ravishankar
1,309 Pointsname="Rakshit" subject = "Treehouse loves {}" subject.format(name) This code of mine is throwing an error.
Challenge task 2 of 2. Using string.format
name="Rakshit"
subject = "Treehouse loves {}"
subject.format(name)
2 Answers
Ryan S
27,276 PointsHi Rakshit,
This challenge wants you to create the subject variable and format the string all in one line:
name="Rakshit"
subject = "Treehouse loves {}".format(name)
Your method would work in normal circumstances (outside of the challenge) but keep in mind that when you use subject.format(name)
, you aren't permanently changing the subject
variable. Instead, you'd need to assign it to the subject
variable again:
# Note: this will not pass the challenge, but it will still accomplish the same thing.
name="Rakshit"
subject = "Treehouse loves {}"
subject = subject.format(name)
Hope this helps.
Rakshit H Ravishankar
1,309 PointsThanks Ryan, This helps.