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 trialDamian McCarthy
3,656 PointsI dont get this!!!
Am I supposed to be inserting the string into the other string like this...
name = format("Damian")
subject = "Tree house loves {name}"
1 Answer
nicole lumpkin
Courses Plus Student 5,328 PointsHi Damian, Not exactly. So the .format()is a function that modifies strings. I think your confusion is rooted in a simple lack of understanding in syntax (which is easily fixed)! The challenge asks you to create a variable called name whose value is a string.
name = 'nicole'
Then you're asked to modify the string "Treehouse loves {}" with the .format() function, and store this result in a variable named subject. Remember the {} indicate a placeholder in which the contents of .format() will be inserted.
name = 'nicole'
subject = "Treehouse loves {}".format(name)
If you were to take a look at subject, you'd see it's value is:
>>>subject
>>>"Treehouse loves nicole"
I hope this helps :)
Clifford Gagliardo
Courses Plus Student 15,069 PointsClifford Gagliardo
Courses Plus Student 15,069 PointsThe challenge is asking to put your name as a string in a variable. Then, use the format() method to let python replace the placeholder curly brackets {} you used in the the subject variable. Here's an example of the format() method in use.
The format() method will replace the empty curly braces {} with what you put between the parentheses (). In this case, I passed the variable town into format() method beings used in the variable named future. So, if you were to print the variable future, it would ultimately read "I would like to live in Portland".
I hope this helps!