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 trialJohn DiGiovanni
Courses Plus Student 902 PointsConfusion as to what exactly this exercise is looking for
Hi, I think Iām confused as to what exactly this exercise is looking for. Do they want me to actually run the function?
# 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!"]
template = "Hi, I'm {name} and I love to eat {food}!"
def string_factory(name = None, food = None):
if name and food:
return("Hi, I'm {} and I love to eat {}!".format(name, food))
else:
return("Ew what is wrong with you.")
1 Answer
Michael Hulet
47,913 PointsNice answer! I turned this comment into an answer so it could be upvoted and marked as best (which it should be imo, but that's up to OP). I also marked your answer in the thread you linked as best, as it's what fixed that OP's problem (and is also one of the general best answers I've seen on this site in a long time)
AJ Salmon
5,675 PointsThank you Michael, I appreciate that!
Steven Parker
231,236 PointsThat other answer certainly gives a new meaning to the word "thorough"!
Michael Hulet
47,913 PointsMichael Hulet
47,913 PointsHey John!
In the future, please refrain from posting profanity in your questions, comments, answers, and any associated code. I've removed the offending phrasing from the last line of the code above