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 trialFHATUWANI Dondry MUVHANGO
17,796 Pointshaving trouble with zippy task.
can you please help me with this code, i feel im close, but missing something
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
# If you use .append(), you'll want to pass it a tuple of new values.
def combo(count, second_t):
for index, letter in enumerate(second_t):
print ('{}, {}'.format(index, letter))
return second_t
2 Answers
Alexander Davison
65,469 PointsThe challenge didn't ask for printing out anything, the challenge is expecting you to return a list.
Also, the first element in the first element of the whole list isn't supposed ot be the index.
You are supposed to use the zip() function, not the enumerate() function.
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
# If you use .append(), you'll want to pass it a tuple of new values.
def combo(iter1, iter2):
combo_list = []
for item1, item2 in zip(iter1, iter2):
# Over here I'm adding a tuple to the list.
combo_list.append((iter1, iter2))
return combo_list
Good luck! ~Alex
FHATUWANI Dondry MUVHANGO
17,796 Pointsthank you guys
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsI wouldn't say that you're supposed to use the zip function here. That's more of a shortcut that does all the work for you.
You're not fully utilizing what the zip function does.
If you're going to use the zip function then you only need to convert the result to a list.
I think the intent of the challenge though was to implement your own zip function.
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsCool