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 trialJoshua Howard
12,798 PointsConfused on why this logic is not working.
I've looked up this question and honestly, I don't understand the working explanation or why mine simply doesn't work.
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
def combo(data1, data2):
a_list = []
for i in enumerate(data1):
a_list += (data1[i], data2[i])
return a_list
1 Answer
Steven Parker
231,269 PointsThe "enumerate" function returns a sequence of tuples, which would not be suitable to use as indexes. You might consider using a "range" instead.
Also, when using the "+=" operator, the expression on the right should be a list. Or you could add a tuple directly using the "append" function.