Python Python Collections (2016, retired 2019) Dictionaries String Formatting with Dictionaries

Alfred Pennyworth
Alfred Pennyworth
6,260 Points

missing 1 required positional argument

I have tried this at workstation and it works. But when it comes to this challenge task it throws error "favorite_food() missing 1 required positional argument: food". Any idea? Thanks in advance.

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

favorite_food(**diction)

1 Answer

Steven Parker
Steven Parker
171,090 Points

The instructions say that the function "accepts a dictionary as an argument", but it looks like you've changed the function signature (number and type of arguments).

You should not change the provided code except to fill in the argument(s) for the "format" function call.

You also won't need to call the function yourself or define any new variables. The challenge validation mechanism will take care of that.