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) Tuples Combo

Why does code not work in challenge?

My code works in workspaces, but does not pass the challenge criteria for some reason, even though I get the exact output the challenge is looking for.

combo.py
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]

def combo(iterable1,iterable2):
    my_list = []
    index = 0
    for iterable in iterable1:
        new_list = [iterable1[index],iterable2[index]]
        my_list.append(new_list)
        index += 1
    return my_list

1 Answer

Steven Parker
Steven Parker
231,236 Points

Maybe you're not getting the exact output the challenge asked for. The instructions say "Your function should return a list of tuples." And that's underlined in the challenge like that (but I would have added it otherwise).

Anyway, you're creating little lists instead of tuples and adding them to the big list. Lists are identified by brackets "[]" and tuples by parentheses "()". Optionally, you could rename "new_list" to "new_tuple" but it will work just as well with any name as long as it contains a tuple.