Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 :)