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

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

what is the right solution for this?

Please help with the correct answer. Thanks!

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

1 Answer

Steven Parker
Steven Parker
231,275 Points

The function is designed to accept a dictionary argument, so you don't need the "splat" operator in the argument definition. But you may want to use it to provide values to the "format" function.

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

what does the correct thing look like?

Steven Parker
Steven Parker
231,275 Points

I'd prefer to help you solve it yourself, I think you'll have a better learning experience that way.

Try applying the hint to your code. If you still haven't passed the challenge, post the revised code and I'll give another hint.

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

Got it finally thanks. Will need to practice this concept a lot :)

Do you know if i could see more examples of usage of packing and unpacking somewhere, or get to practice it?

Steven Parker
Steven Parker
231,275 Points

I'd bet you could find some online resources, but it also sounds like a great suggestion for another "practice workshop".

You could make the suggestion directly to the staff as decribed on the Support page.