title: recursive merge sort in python
body: <p>I am trying to make merge sort using two functions in python. But I got an error like<br>
  <strong>IndexError: list assignment index out of range</strong> whenever run my code. I don't know which part is wrong.<br>
  This is my code below. 
  Any help will appreciate!!</p>
  
  <pre><code>def merge(A):
  
      def merge_sort(A,first,last):
          if first&lt;last:
              mid=(first+last)//2
              merge_sort(A,first, mid)
              merge_sort(A,mid+1,last)
  
              temp=[]
              temp.append(99999)
              i=first
              j=mid+1
              k=0
              while i&lt;=mid and j&lt;=last:
                  if A[i]&lt;=A[j]:
                      temp[k]=A[i]
                      k=k+1
                      i=i+1
                  else:
                      temp[k]=A[j]
                      k=k+1
                      j=j+1
              while i&lt;=mid:
                  temp[k]=A[i]
                  k=k+1
                  i=i+1
              while j&lt;=last:
                  temp[k]=A[j]
                  k=k+1
                  j=j+1
              a=0
              b=first
              while a&lt;k:
                  A[b]=temp[a]
                  b=b+1
                  a=a+1
  
      merge_sort(A,0,len(A)-1)
  
      return A
  </code></pre>