18: Using a list of lists in a function, no idea about error message


#1



I'm not sure what is going wrong, please help!

This is the error message I am getting:

Traceback (most recent call last):
File "python", line 11, in
File "python", line 7, in flatten
TypeError: 'builtin_function_or_method' object has no attribute 'getitem'


I have no idea what the error message means. :cry:


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


print flatten(n)


#2

append() is a built in function to append to lists, which uses parentheses. using square brackets means you try access by index


#3

Thank you, it works perfectly now


#4