def swap(x, j, k): """ x is a list. swaps entries j and k in the list.""" if j != k: x[j], x[k] = x[k], x[j] def clear(x): x = [] x = [1,2,3,4] print(x) swap(x, 1,3) print(x) clear(x) print(x)