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

it's not working not able to find solution


def favorite_food(name=None,food=None):
    return "Hi, I'm {} and I love to eat {}!".format(name,food)

3 Answers

It looks like the original function didn't have the same argument list. It just took "dict", i.e. a dictionary for argument.

So the question is, how do you unpack it so its values can be used in the format() call?

If I were in the dict, my name key would have a value of "Barry". So, dict['name'] would be "Barry". dict['food'] would be whatever I was eating.

So you basically need to just put the two values in the format call. Since you can't access "Barry" or whatever the name is, how would you represent it? How would you represent "tacos" or whatever I like to eat? All you have are key names.

thanks sir!!

Were you able to complete the challenge? Let me know if you're still unsure how to go about it. Good luck!

yes Sir!! I completed my challenge with your precious advice