Can any one tell me what is wrong in my code


#1

n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]

def flatten(lists):
    results=[ ]
    for numbers in lists:
        for n1 in numbers:
            #print(n1)
            results.apppend(n1)
    return results                    
    
print flatten(n)

it is giving error :AttributeError: 'list' object has no attribute 'apppend'


#2

You must have only one loop, where you loop over the parameter lists. Reason for looping over the parameter is that it makes possible to use your function in different lists.


#3

please can you explain?? i am not getting it


#4

So you updated your code? Good. But now you have a typo in the line number #8.

results.apppend()

#5

thanku so much :slight_smile: work it


#6

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