Using a list of lists in a function


#1



please i do not what is wrong with my code


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



print flatten(n)


#2

To find out you would start by establishing what it's doing differently from what it should be doing.

Or, if you're not getting that far, then you would show that you have tested it and argue for why your tests indicate that it behaves correctly and then ask for help in finding out in what way it misbehaves.

So far you've posted your code and .. pretty much ask others to do the rest. It's much better for everyone if you instead ask about how you can continue, and to do that you need to explain what you've done so far and what's got you stuck.


#3

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