Assuming that your code is something like yang3's, the problem is that A is passed by reference, but the overwriting (A=[0]*n) is changing which array A is pointing to. Since you return nothing, the original array is being observed from outside the function and by overwriting A, any changes in it will not propagate to the outside array. Therefore, the original value, [0], is what the function sees you having returned.

I assume that what you did to check your answer was print A inside the merge function, or returned A and printed the returned value? If so, that is using the local reference you changed it to, not the one leetcode is checking for correctness, which is the original array passed in.

As the description says, `# @return nothing.`

```
def merge(self,A,m,B,n):
if n!=0:
while m>0 and n>0:
if A[m-1] < B[n-1]:
A[m+n-1] = B[n-1]
n=n-1
else:
A[m+n-1] = A[m-1]
m=m-1
while n>0:
A[n-1] = B[n-1]
n=n-1
```

**EDIT** The original inputs, while stating that A=[] and B=[1], aren't quite what is passed in. Under the assumption from the problem description, A has space for B to be added to it. In this version, that space is represented by a string of 0s equal in length to B at the end of A. Because of this, the A passed in is actually [0], since it is the empty list, with one 0 appended to it.

**EDIT2** Thanks to now having the code, I believe I've identified what is happening. You do A.extend(B), changing A from [0] to [0,1]. You then sort it, which has no effect, as it is already sorted. The problem arises from the tester, which knows there are n+m elements, 1 in this case, so only looks at the first n+m (1) indices of your array. That is the [0]. Your solution assumes there isn't space for B to be added to A. Instead of `A.extend(B)`

, try `A[m:]=B`

That allows B to be placed in A, without leaving the empty spaces.

```
def merge(self,A,m,B,n):
A[m:]=B
A.sort()
```

was accepted for me.