18. lists and functions


Why do you have to loop it twice?
I just copied the answer from another topic because I wanted to move on but I don't understand.

2nd question; what does the word "numbers" link to then? to nothing?

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

print flatten(n)

print flatten(n)


If you copy, you indeed won't understand.

I recommend to add some print statements so you can actually "see" what your code is doing.

numbers is the iterator of your first loop


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