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

Thomas Trabue
Thomas Trabue
11,819 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,546 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,819 Points

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