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

Combo

When I run this code in Workspaces it gives me back separate lists each containing a tuple. am I at least on the right track? Any help would be great, thanks.

combo.py
def combo(iterable1, iterable2):
    index = 0
    while index < len(iterable1) and index < len(iterable2):
        letter1 = iterable1[index]
        letter2 = iterable2[index]
        index = index + 1
        tup = (letter1, letter2)
        my_list = []
        my_list.append(tup)

        return my_list

2 Answers

Oszkár Fehér
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Oszkár Fehér
Treehouse Project Reviewer

Hi Matthew, Actually the code contains everything to pass the challenge just one indentation and a variable definition

def combo(iterable1, iterable2):
    index = 0
    while index < len(iterable1) and index < len(iterable2):
        letter1 = iterable1[index]
        letter2 = iterable2[index]
        index = index + 1      <<---here
        tup = (letter1, letter2)
        my_list = []         <<--- this variable it should be defined outside of while loop
        my_list.append(tup)

        return my_list           <<--- the indentation, it should be in the same column with the while loop, outside of the loop
def combo(iterable1, iterable2):
    index = 0
    my_list = []
    while index < len(iterable1) and index < len(iterable2):
        letter1 = iterable1[index]
        letter2 = iterable2[index]
        index += 1
        tup = (letter1, letter2)      
        my_list.append(tup)
    return my_list

Keep up the good work. Happy coding

Thanks Oszkár, that helps a lot :)