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!
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 trial
frederik christensen
5,740 PointsWhat does this do again {} ?
So i am learning python but i see craig use this alot of time " {} " and as far as i remember he called it a placeholder. But what does it do?
1 Answer

Cooper Runstein
11,849 PointsMost likely you're seeing it used in situations like this:
string = "Hello {}".format("world")
The {} serves as a placeholder for the text that you insert with the format function. So right now, if you printed out the variable string, it would return "Hello world".
string2 = "Hello {}".format("frederik")
Here string2 becomes "Hello frederik"
Kailash Seshadri
3,085 PointsKailash Seshadri
3,085 PointsUnless you specify world, or frederick, as a variable e.g:
In this case, a print (string) will output Hello Bob
NB: Notice that in the .format brackets, the word world now doesn't have a "". This is so that the format does not treat the world as a string, and instead as a variable. So:
In this case, a print(string) will output Hello world, because the world is now treated as a string, not as a variable.