The mergesort function you call doesn’t modify its argument. Rather, it returns a new sorted list.
A simple fix would be:
def mergesort(data):
if len(data) < 2:
return data # Fix1
left = data[:len(data)//2]
print(left)
right = data[len(data)//2:]
print(right)
print("left only now")
left = mergesort(left) # Fix2
print("right now")
right = mergesort(right) # Fix3
return merge(left,right)
data = mergesort([1,20, 30, 25, 8, 7, 9])
1
solved Mergesort Python implementation