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

how would i unpack this dictionary?

 def foods(jason = {"name": "jason", "food": "tacos"}):
    return "hi, I'm {name} and i love to eat {food}!".format(**jason)
foods() 

I did the code challenge, i was just trying to do this on my PC and it litteraly returns nothings it just reset the python line to wait for another entry. How would i unpack a dictionary here to make it say, Hi im jason and i love to eat tacos?

1 Answer

Tamás Szentmiklóssy
Tamás Szentmiklóssy
8,188 Points

jason = {"name": "jason", "food": "tacos"} def foods(d): return "hi, I'm {name} and i love to eat {food}!".format(**d) foods(jason)