18.Using a list of list in a function..Small Doubt!


Hello Everyone.. I just have a little doubt,can somebody explain it?
my code is:
n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]

Add your function here

def flatten(lists):
for numbers in lists:
for members in numbers:
return results
print flatten(n)

it works fine,but why can't i run the program when line is:
results = results.append(members)
it throws error!
Traceback (most recent call last):
File "python", line 12, in
File "python", line 7, in flatten
AttributeError: 'NoneType' object has no attribute 'append'

Can somone explain why can't i store the results.append(members)
in results??????????


I'm not good explainer, but i will try
the method append() appends a passed obj into the existing list.
syntax : list.append(obj)

This method does not return any value but updates existing list.
so you can't stock the return value of append() to results


Thanks i got it :smile: