Python Python Collections (2016, retired 2019) Tuples Combo

Thomas Trabue
Thomas Trabue
11,806 Points

Can't figure out what is wrong with my answer to the "combo" problem...

Hello ladies and gentlemen,

I feel pretty silly for asking this, but I simply cannot see what is wrong with my answer to the "combo" problem at the end of one of the Python Collections modules. Here is Kenneth Love's description of the problem:

Create a function named combo that takes two ordered iterables. These could be tuples, lists, strings, whatever. Your function should return a list of tuples. Each tuple should hold the first item in each iterable, then the second set, then the third, and so on. Assume the iterables will be the same length.

My code should be attached. I have run it on a number of test cases and they all came out correct, and I am not getting any useful output from the Treehouse answer checker. Thanks in advance!

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

def combo(iter_a, iter_b):
    length = len(iter_a)
    combo_list = []
    for i in range(0, length):
        combo_list.append((iter_a[i], iter_b[i]))
    return combo_list

1 Answer

Eric M
Eric M
11,493 Points

Hi Thomas,

Your code is good! It passed the challenge for me on a copy/paste.

It seems like you're running into an issue with the workspaces. This can happen sometimes, I personally experienced it a couple of times going through the Treehouse Python material.

If you log out of Treehouse, clear your browser cache, and restart your browser you should be able to come back and complete the challenge.

Sorry, I know it's frustrating!

Cheers,

Eric

Thomas Trabue
Thomas Trabue
11,806 Points

Thanks so much for the quick response, Eric! That did it! I'll have to bear that in mind as I move forward.