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 trialIvan Bodnar
2,419 PointsPython 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.
# 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
Treehouse Moderator 68,441 PointsYour 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
Ken Alger
Treehouse TeacherIvan;
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
2,419 PointsYou 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!
Ivan Bodnar
2,419 PointsIvan Bodnar
2,419 PointsYes, true. Plus, I guess your for loop is more "pythonic", as they say. Thanks!