Using a list of lists in a function


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/4/2?curriculum_id=4f89dab3d788890003000096#

Oops, try again. flatten([[1, 2], [3, 4]]) returned [1, 2] 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 num in numbers:
            results.append(num)
        return results

print flatten(n)


#2

Problem.
return results

Hint...
Indent it at same level as for loop


#3

perfect
thanks!
its weird how incorrect indenting can stuff things up
i had been stuck on that for ages! thanks


#5

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