Using a list of lists in a function


The code seems to fine but it shows the error message that flatten([[1,2],[3,4]]) returned [[1,2],[3,4]] instead of [1,2,3,4]

n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]
# Add your function here
def flatten(lists):
    results = []
    for numbers in lists:
        for i in numbers:
    return lists

print flatten(n)


you return lists, but your flattend list is stored in results


Oh man.. silly mistake.. Thanks for the help::+1:


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