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 trialAndrew McLane
3,385 PointsWhy does code not work in challenge?
My code works in workspaces, but does not pass the challenge criteria for some reason, even though I get the exact output the challenge is looking for.
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
def combo(iterable1,iterable2):
my_list = []
index = 0
for iterable in iterable1:
new_list = [iterable1[index],iterable2[index]]
my_list.append(new_list)
index += 1
return my_list
1 Answer
Steven Parker
231,269 PointsMaybe you're not getting the exact output the challenge asked for. The instructions say "Your function should return a list of tuples." And that's underlined in the challenge like that (but I would have added it otherwise).
Anyway, you're creating little lists instead of tuples and adding them to the big list. Lists are identified by brackets "[]" and tuples by parentheses "()". Optionally, you could rename "new_list" to "new_tuple" but it will work just as well with any name as long as it contains a tuple.