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


Combos challenge output seems correct but not passing

When I run this in workspace it seems fine, but it fails the challenge. What am I doing wrong?

def combo(keys,value_string):
    tup_list =[]
    for key in keys:
        tup = key, value_string[key-1]
    return tup_list

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Your solution seems to bank on the keys array being exactly as in the sample data. This is an incorrect assumption. The data used to grade the challenge is not guaranteed to be the same as the sample data. Your solution needs to be more generic to handle any data, such as, combo(['a', 'b', 'c', 'd'], ['Z', 'Y', 'X', 'W']).

Try using a generic index to build each tuple, such as:

for index in range(len(keys)):
    tup = keys[index], value_string[index]

# OR
for index, key in enumerate(keys):
    tup = key, value_string[index]