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 trialSean Frye
1,167 PointsDamn. I forget what to do.
I'm obviously missing something, but I forget what. I haven't had consistent time to work on this.
name = 'Sean'
subject = "Treehouse loves {}.format('Sean')"
3 Answers
angel moreta
2,912 PointsInside of .format() <β- type name instead of βSeanβ
Antonio De Rose
20,885 Points#treehouse question
#OK, now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the #variable subject (so start with subject =).
#You do not need to print() anything.
#treehouse end of question
name = 'Sean'
subject = "Treehouse loves {}.format('Sean')" #the name should print instead of the placeholder
#if you directly place the your name, there is no value for the placeholder
#you are saving a variable at the start in the name of name with the value in it
subject = "Treehouse loves Sean"
#above is a direct print
subject = "Treehouse loves {}" #we want something to substitute {}, hence we are reserving place
#now, what do we want there is the name which is in the form of a variable, and
#when the python code runs, it will interpolate the variable with the placeholder
#and put the value at the right place
#how could be the code interpolated
subject = "Treehouse loves {}"
#have to concatenate, to join a string with the format method
#why format method - that will help interpolating the name variable with the value replacing the {}
subject = "Treehouse loves {}.format('Sean')" #replace 'Sean' with the variable name you assigned
#hint - think of where would the dot operator comes, the place you have put is wrong
Antonio De Rose
20,885 Pointsabsolutely, .format(name), will interpolate the name variable's value inside {} place, when the code is run.