Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


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,179 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]