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

Ivan Bodnar
Ivan Bodnar
2,419 Points

Python Collections Challenge 1 of 1 (tuples)

This code worked on the workspace. Plus, the error message says "expected (10, 'T'), got (10, 'T') instead. I guess it's a bug.

zippy.py
# 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(it1, it2):
  result = list()
  n = 0
  for x in it1, it2:
    result.append((it1[n], it2[n]))
    n += 1
  return result

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Your current code is not that far off. It will pass if you alter the for loop slightly:

def combo(it1, it2):
  result = list()
  for n in range(len(it1)):
    result.append((it1[n], it2[n]))
  return result
Ivan Bodnar
Ivan Bodnar
2,419 Points

Yes, true. Plus, I guess your for loop is more "pythonic", as they say. Thanks!

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Ivan;

Welcome to Treehouse!

The issue is with your for statement. We only need to iterate over the first item to be able to get the proper results.

Post back if you are still stuck or have further questions.

Happy coding,
Ken

Ivan Bodnar
Ivan Bodnar
2,419 Points

You are right!

I'll check it in more depth in a console anyway, because I don't quite get what is happening behind the scenes...

Thank you!