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 trialMUZ140934 Noel Zipingani
2,656 PointsCreate 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
# 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
27,771 PointsHi, You're missing a closing bracket ')' on your 2nd last line
Hanley Chan
27,771 PointsHi,
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
MUZ140934 Noel Zipingani
2,656 Pointsthanks i got it
Joe Law
5,040 PointsHeyNoel Zipingani, do you mind to explain abit about your coding?
MUZ140934 Noel Zipingani
2,656 PointsMUZ140934 Noel Zipingani
2,656 Pointsstill 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')]