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 trialIan Maina
4,571 Pointsi honestly don't get this challenge
what am i being asked here? i don't get it.
# 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):
template = "Hi, I'm {} and I love to eat {}!"
return template.format(name, food)
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYou have the basic idea, now add the two missing parts:
-
values
will be list of dict. Add a loop to apply each of the name/food combinations to the template - create a list of the formatted templates and return it
Post back if you need more help. Good Luck!!
Ian Maina
4,571 PointsIan Maina
4,571 Pointswhy is it telling me this? I couldn't import
string_factory
.Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsIf there is a syntax error then the object
string_factory
does not get created. This causes the challenge checker to get anNameError
due to object not found.Post your latest code if you need more help. Good luck!!