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

didn't getting the combo value

I don't know what's happening...My code is.......

def combo(num,string):
    mylist = []
    str = list(string)
    count = 0
    while count > len(num):
        a = num[count],string[count]
        print(a)
        mylist.append(a)
        count += 1
 print(mylist)

1 Answer

Hello Af,

Your code isn't returning anything, as the Challenge requests; it also declares a variable str which isn't used anywhere. I'd also recommend using a format of for items in range of the length of the list instead of while, which skips the need for a count and simplifies the code.

def combo(num,string):
    mylist = []
    for nums in range(len(num)):
        mylist.append((num[nums], string[nums]))
    return mylist

The class hasn't covered this yet, but you could also use the zip() and list() functions to make this even simpler;

def combo(num, string):
  return list(zip(num, string))

Hope that helps!

Thanks a lot Evan for this help.....