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

Ashley Keeling
Ashley Keeling
11,476 Points

I don't know what I need to do next

I don't know how you put a letter together with a number (1,"A")

combo.py
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]


def combo(st,i):
    i1=i.split()
    st1=st.split()
    return(st1,i1)

There are a bunch of ways to do this

1) loop over a range

snippet.py
ret = []
for index in range(0, len(st)):
    ret.append( (st[index], i[index]) )
return ret

2) loop over enumerate

snippet.py
ret = []
for index, cc in enumerate(st):
    ret.append( (cc, i[index]) )
return ret

3) or zip (which we are actually rewriting for this challenge)

snippet.py
return zip(st, i)

I would take a moment and read the python docs for those three options. They will all be useful for you in the future.

Steven Parker
Steven Parker
231,236 Points

But "zip" doesn't produce a list. However, you could convert it into one:

    return list(zip(st, i))

But you still can't pass the challenge with that. It will say "Bummer! Don't use zip()! I know it exists but the point of this challenge is to solve the problem yourself." :wink: