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

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,870 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?