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 trialUnsubscribed User
1,539 PointsChallenge Task difficulties with .format string.
I'm having difficulties with the .format task challenge. I've tried: variable = "name" name = "Alina" variable = "subject" subject = "Treehouse loves {}" print(subject.format('Alina'))
with no luck. I've even tried format(name) and the task challenge says it is not correct. But I've tried this within the workspace and it worked. Not sure why the challenge task is not accepting it.
variable = "name"
name = "Alina"
variable = "subject"
subject = "Treehouse loves {}"
print(subject.format('Alina'))
print(subject.format(name))
print(subject.format('name'))
1 Answer
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 PointsGood day, you are over thinking it.
In the first part, you set the name variable.
In the second, we just need set the variable subject with the given string. We then use format to put the name into the placeholder.
name = 'fred'
subject = "Treehouse loves {}".format(name)