Welcome to the Treehouse Community
Looking to learn something new?
Alexandru Patriche10,466 Points
Tuples, Combo Challenge advice
I wrote the code below and when I test it locally it works but not perfectly. Calling combo([1, 2, 3], 'abc') returns only [(2, 'b')]. I take it as I'm relatively on the correct path but could use some advice, please.
# combo([1, 2, 3], 'abc') # Output: # [(1, 'a'), (2, 'b'), (3, 'c')] def combo(iterable1, iterable2): tuple_output =  x=0 for iterable in iterable1, iterable2: tuple_output = [(iterable1[x], iterable2[x])] x+=1 return tuple_output
Eduardo Valencia12,444 Points
Hey. This is because you are setting the
tuple_output equal to the new tuple you generate in your for loop in lieu of appending it to the
tuple_output. Consequently, it will always be set to the last generated tuple in your for loop. To fix this, simply append a tuple using the
.append() method in lieu of setting it equal to an array with a tuple.