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

Alfred Pennyworth
Alfred Pennyworth
7,691 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
230,024 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.