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 Python Collections (2016, retired 2019) Dictionaries String Formatting with Dictionaries

Blue Miles
Blue Miles
5,826 Points

Why is this not correct?

You've used the string .format() method before to fill in blank placeholders. If you use a placeholder of {food} in the string, then you pass a keyword argument of food to .format(). The {food} placeholder in the string will be replaced with the value of the food keyword argument.

"Hi, I'm {name} and I love to eat {food}!".format(name="Kenneth", food="tacos")

Was it the fact that I said, "sushi bowl and burrito" or more to do with the actual code itself?

string_factory.py
def favorite_food(dict):
     dict = {"name": "Blue", "food": "Sushi Bowls and burritos"}
     return "Hi, I'm {name} and I love to eat {food}!".format(**dict)

1 Answer

Steven Parker
Steven Parker
230,231 Points

Your function should work with the value that is passed in. Assigning "dict" replaces the passed value, which is then lost.

This challenge task is simply to fill in the argument to the "format" call.