Merge sort algorithm written in Python def merge_sort(mslist):

    if len(mslist) &lt; 2:
        return mslist

    left = mslist[:int(len(mslist)/2)]
    right = mslist[int(len(mslist)/2):]

    left = merge_sort(left)
    right = merge_sort(right)

    return merge(left, right)

def merge(left,right):

    result = []

    while len(left) &gt; 0 or len(right) &gt; 0:
        if len(left) &gt; 0 and len(right) &gt; 0:
            if left[0] &lt;= right[0]:
                result.append(left[0])
                left.pop(0)
            else:
                result.append(right[0])
                right.pop(0)
        elif len(left) &gt; 0:
            result.append(left[0])
            left.pop(0)
        elif len(right) &gt; 0:
            result.append(right[0])
            right.pop(0)

    return result

def main():

    mslist = [-9,1,1,2,3,2,7,3,6,4,5,4,3,5,6,7,8,9,0,0]
    print(merge_sort(mslist))

if __name__ == "__main__":
    main()



Please give me some comments about the actuall algorithm, i used the pseudo code from the wikipedia page as a reference.
Please give me some Pythonic advice or any other general coding paradigm you  feel should be followed.


I already made changes to my code regarding the amount of times len(direction) is done.
Here:

if len(mslist) &lt; 2:


I would write len(mslist) &lt;= 1 because 1 is the interesting number here.

Here:

int(len(mslist)/2)


just write len(mslist)//2 which is explicit integer division.

Here:

            result.append(left[0])
            left.pop(0)


you can write result.append(left.pop()) since pop returns the element removed.

The elifs in the merge function are not properly aligned.

Notice that the use of the pop method could alter algorithm complexity (because I think that pop is \$O(n)\$). It could be better to use two indices to keep track of the position in the two lists.