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 trialJeanMartin Ghecea
5,770 PointsWas there a typo in this challenge description?
In this challenge description the author wrote: "Write a function named string_factory that accepts a list of dictionaries as an argument. "... Was this meant to be "a list OR dictionaries"? Then one would understand it would be a '**kwargs' argument for both. Please advise.
2 Answers
andren
28,558 PointsNo the description is accurate. The argument provided is a list of dictionaries. It even shows an example of the type of argument it will pass in [{"name": "Michelangelo", "food": "PIZZA"}, {"name": "Garfield", "food": "lasagna"}]
, which is indeed a list of dictionaries.
kwargs is not used in this challenge, the unpacking is meant to be done as you format the string. Since the format
method accepts key-value pairs you can use unpacking to provide it with values. Here is a simple example:
dict = {"name": "AndrΓ©", "food": "Pizza"}
print("My name is {name} and my favorite food is {food}".format(**dict))
# "My name is AndrΓ© and my favorite food is Pizza" will be printed out
Since you receive multiple dictionaries in the challenge you will need to loop though them. And generate a list of strings which you then return.
Edit: Fixed some syntax errors in my code example.
JeanMartin Ghecea
5,770 PointsThank you. Yes, indeed it was my faux pas. I finally figured out the solution to the problem. I have learned that there are many things implied in these videos that one has to think through. It definitely makes it challenging and fun at the same time once one has thought through it. I appreciate the clarification andren.