Q:

Why is my python merge sort not working? 

Can you please look at the below code and help me understand why my merge sort code is not working?  I have done many changes to this code, I tried to add +1 and remove -1 from indexes wherever possible, but I couldn't debug it. 
#! /usr/bin/python
def Merge(a,p,q,r):
    n1=q-p+1
    n2=r-q
    (l,ri)=([],[])
    for i in range(n1):
        l.append(a[p+i])
    for j in range(1,n2+1):
        ri.append(a[q+j])
    l.append(float('inf'))
    ri.append(float('inf'))
    print 'l and ri are %s and %s' % (l,ri)
    i=0
    j=0
    for k in range(p,r+1):
        if l[i]<=ri[j]:
            a[k]=l[i]
            i+=1
        else:
            a[k]=ri[j]
            j+=1
    print 'a after merge is %s' % (a)

def MergeSort(a,p,r):
#print 'a,P and r are %s, %d and %d' % (a,p,r)
    if p+1<r:
        q=divide(r-p)
        MergeSort(a,p,q)
        print 'After MS of %d and %d' % (p,q)
        MergeSort(a,q+1,r)
        print 'After 2nd MS of %d and %d' % (q+1,r)
        print 'Before Mer of %d and %d and %d' % (p,q,r)
        Merge(a,p,q,r)

def divide(number):
    Q,R=divmod(number,2)
    return Q+int(bool(R))

if __name__=="__main__":
    a=[2,9,6,5,4]
    MergeSort(a,0,len(a)-1)
    print a

Is it because my array starts with 0 index? 

A:

This code should be working. 
While I usually don't support debugging solutions, there were many problems with yours.  I believe it would be good for you to share your code on Code Review StackExchange site in order to get further useful comments and practices. 
The issues I found with your code are along the lines of:

Awful representation of indices.  You used both closed and half-open intervals.  If you can invest some time in improving your understanding of this, you won't make so much off-by-one errors or fixes. 
No spacing - your code was simply unreadable.  While I didn't spend much time on editing it for clarity, you can clearly see my changes to make it more readable. 
Other small mistakes, which show poor understanding of either the merge sort algorithm, or the programming language  - for example the line q=divide(r-p).  If p = 8 and r = 10, then you would get q = divide(2), which is 1.  Therefore, you will call MergeSort(a, 8, 1) and MergeSort(a, 2, 10) - this is terribly wrong. 
Naming conventions, you can help yourself by using meaningful variable names.  This will significantly improve your debugging time. 

Hope this helps!