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

Python

Long 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

It'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)

Ooooh I see, thank you so much !!!