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

Code challenge not working but executing in workspace

I'm having a challenge of executing the code challenge, which I have tested in workspaces however, and is working

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

1 Answer

Steven Parker
Steven Parker
231,269 Points

Sure, that function works, but only if you give it two string arguments. It uses a different function signature than what's in the challenge. The function in the challenge takes a single dictionary argument, and the challenge is going to pass it a single dictionary argument when it tests it.

Your task is to use that dictionary to create the proper output. Don't change the "def" line!

Samuel Pitt
Samuel Pitt
3,032 Points

[EDIT:] original"Hi Steven Parker, could you elaborate. I'm stuck too. do we need to use dict{something something} in the format line? the 'def' line contains only dict in the arguments..."

i worked it out!!!! the question doesnt inform you that it will pass its own values in and simply use your function. leave the original line 1 unchanged, then in the format, unpack "dict". HINT: **

Steven Parker
Steven Parker
231,269 Points

Simbarashe Banga — did you get it too? You can mark a question solved by choosing a "best answer".