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 trial
Stivan Radev
1,475 PointsLong break from Python - Forgot some of the stuff
So I'm trying to run this code
display = "I like {}!"
display.format("candy")
print(display)
and the obvious answer should be, "I like candy!", but no, for some reason It is printing this out instead "I like {}!". Why is that?
1 Answer
Viraj Deshaval
4,874 PointsIt's displaying "I like {}" because {} is a placeholder and it should be filled with something.
.format() is used to fill out the placeholders so in your code you did correctly but you need to assign it to some variable because .format() do not change variable values. See below.
display = display.format("candy")
print(display)
Stivan Radev
1,475 PointsStivan Radev
1,475 PointsOoooh I see, thank you so much !!!