Using a list of lists in a function


My code looks like this:
def flatten(lists):

def flatten(lists):
    results = []
    for numbers in lists:
    return results

What is the problem with it? I've got this note:

Oops, try again. flatten([[1, 2], [3, 4]]) returned [0, 1] instead of [1, 2, 3, 4]


What you did is appending index of item instead of value. You iterate twice for indexes 0 and 1. You must take a value of item under those indexes so :

results.append(lists[numbers]) This is how you append values from list with index of numbers.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.