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 (Retired) Tuples Combo

Create a function named combo() that takes two iterables and returns a list of tuples. Each tuple should hold the first

where am l getting this code wrong ... help please

zippy.py
# combo(['swallow', 'snake', 'parrot'], 'abc')
# Output:
# [('swallow', 'a'), ('snake', 'b'), ('parrot', 'c')]
# If you use list.append(), you'll want to pass it a tuple of new values.
# Using enumerate() here can save you a variable or two.
def combo (iterable_1 , iterable_2):
  tuple_list = []
  for item in enumerate(iterable_1):
    tuple_list.append((item[1], iterable_2 [item [0]])
  return tuple_list   

2 Answers

Hanley Chan
Hanley Chan
27,771 Points

Hi, You're missing a closing bracket ')' on your 2nd last line

still my code doesnt work get this bummer Got [(1, 'T')], expected [(1, 'T'), (2, 'r'), (3, 'e'), (4, 'e'), (5, 'h'), (6, 'o'), (7, 'u'), (8, 's'), (9, 'e')]

Hanley Chan
Hanley Chan
27,771 Points

Hi,

I copied and pasted your code adding the missed bracket and it passed the challenge

# combo(['swallow', 'snake', 'parrot'], 'abc')
# Output:
# [('swallow', 'a'), ('snake', 'b'), ('parrot', 'c')]
# If you use list.append(), you'll want to pass it a tuple of new values.
# Using enumerate() here can save you a variable or two.
def combo (iterable_1 , iterable_2):
  tuple_list = []
  for item in enumerate(iterable_1):
    tuple_list.append((item[1], iterable_2 [item [0]]))
  return tuple_list   

thanks i got it

Joe Law
Joe Law
5,040 Points

HeyNoel Zipingani, do you mind to explain abit about your coding?