Adding python version of counting inversions