Someone eaten my [4]. NEED HELP


#1

Hi. Have mistake. Can not understand how to solve this error and why this error appear.

n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]

def flatten(lists):
    results = []
    for i in n:
        for number in i:
            results.append(number)
    return results

print (flatten(n))

error:

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


Thanks.

!!!! IT WORKS. EVERYTHING IS DONE.
HERE IS SOLUTION

def flatten(lists):
    results = []
    for i in lists:
        for number in i:
            results.append(number)
    return results

#2

def flatten(lists):
    results = []
    for i in lists:
        for number in i:
            results.append(number)
    return results

#3

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