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 trialOng Jia Rui
1,731 Pointsstring_factory() takes 0 positional arguments but 1 was given?
What does this mean? string_factory() takes 0 positional arguments but 1 was given
# Example:
# values = [{"name": "Michelangelo", "food": "PIZZA"}, {"name": "Garfield", "food": "lasagna"}]
# string_factory(values)
# ["Hi, I'm Michelangelo and I love to eat PIZZA!", "Hi, I'm Garfield and I love to eat lasagna!"]
def string_factory(**values):
if name and food:
template = "Hi, I'm {} and I love to eat {}!".format(name,food)
else:
print("Hi no name!")
return template
1 Answer
Steven Parker
231,269 PointsYou haven't specified the argument as the challenge expects.
The challenge says your function should accept a "list of dictionaries as an argument", but you defined your function to take a variable-sized keyworded list using the packing operator (**
).
Here's a few more hints that may help:
- you accept an argument named values, but it is never used inside the function
- to handle a list of items you will need some kind of loop
- you will need to construct a dictionary instead of a string as the return value
- your function does not need to print anything