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 trialOng Jia Rui
1,731 PointsUsing zip()
I tried using zip() function to return results for this challenge, but I don't understand why the output is incorrect.
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
def combo(x, y):
return zip(x, y)
2 Answers
William Li
Courses Plus Student 26,868 PointsI think it's pretty clear on the Bummer! message you received from using zip()
to solve this problem. The instructor wants you to get some practices on the materials covered in the previous lectures, which means solving this code challenge by applying the Python knowledge we've learned so far in the course.
I agree that list(zip(x,y))
is a shortcut to solving this problem, but the whole idea of this code challenge is that you're supposed to write a simplified version of zip()
in your own code; and making use of the zip()
written by someone else defeats the purpose of practicing.
Ong Jia Rui
1,731 PointsOkay, I have seen list(zip(x,y)) work. But from my console, I see that zip() itself returns a list, so why can't it pass?
Jason Anello
Courses Plus Student 94,610 Pointszip() returns an iterable. You have to explicitly convert it to a list if that's what you need.