Python Python Collections (2016, retired 2019) Tuples Combo

Keep tell me try again...... Please help

question

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

def combo(iterable_1,iterable_2):
    list_of_tuples = []

    for index, item in enumerate(iterable_2, start = iterable_1[0]):
        list_of_tuples.append((index,item))
    return list_of_tuples 

1 Answer

Dave StSomeWhere
Dave StSomeWhere
19,809 Points

Pretty close, double check what's happening with your enumerate()

Try testing with below:

#  test1
print(combo([1, 2, 3, 2, 3], 'abdec'))
# test2
print(combo(['x', 2, 3, 2, 3], 'abdec'))

#  your incorrect actual output
#  output 1
[(1, 'a'), (2, 'b'), (3, 'd'), (4, 'e'), (5, 'c')]
#  output 2
File "Path stuff...", line number, in combo
    for index, item in enumerate(iterable_2, start=iterable_1[0]):
TypeError: 'str' object cannot be interpreted as an integer

#  desired output
#  output 1
[(1, 'a'), (2, 'b'), (3, 'd'), (2, 'e'), (3, 'c')]
#  output2
[('x', 'a'), (2, 'b'), (3, 'd'), (2, 'e'), (3, 'c')]

Does that point out your bug?