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

austin bakker
austin bakker
7,105 Points

could not import

i keep on getting a bummer i coud not import... Im not sure what the problem is, could someone explan this to me

string_factory.py
# 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 sting_factory(name=None,food=None):
    template = "Hi, I'm {} and I love to eat {}!".format(name,food)

2 Answers

austin bakker
austin bakker
7,105 Points

this is what i can up with. But im pretty sure there is a shorter way to write this peace of code. If anyone has any feedback please let me know.

def combo(lists, string):
    temp_list = list()
    temp_list2 = list()
    final_list = list()
    for letter in lists:
        temp_list.append(letter)

    for letter1 in string:
        temp_list2.append(letter1)

    for times in string:
        tulp = temp_list.pop(0), temp_list2.pop(0)
        final_list.append(tulp)
    print(final_list)

combo([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'string')
Ryan Cross
Ryan Cross
5,742 Points

couple of ideas 1 ) you didn't return anything here. 2) typo on sting_factory 3)The challenge says "string_factory that accepts a list of dictionaries as an argument." the way you coded here would work if you were to be given two keyword pairs...but you aren't