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 (2016, retired 2019) Tuples Combo

returning an enumerate object.

Right now my code unpacks the arguments within the function(at least thats what I think). Then gets put into the list. Just printing out the list returns [[1,2,3], 'abc']. So, I thought the enumerate build in function would work, but I'm still getting an error.

combo.py
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
def combo(*args):
    args = list(args);
    return enumerate(args,1);

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

you're pretty close. you are enumerating args, but that is a tuple with a list of numbers and a string (ie two iterables) as its elements. enumerate takes care of the numbering, that's why you're supplying it with a start value of 1, so you don't need to supply the entire args to it, just the part that isn't numbers. so slice into args to get the non-numbers so enumerate can match them with the numbers it generates. then, you need to cast the result into the form requested by the challenge, since enumerate by itself will not return the values in the requested form. with those changes you will pass, but additionally you don't need semicolons at the ends of lines in python, and you also don't need to cast args to a list.

Hey James,

I tried for a while. Could you provide the result you were thinking of based on my code? Thanks in advance.