+ 2
Is there a list function that swaps two items in a list?
Example: Suppose that 'swap' is a list function: list = ['a', 'b', 'c', 'd'] list.swap(0, 3) print(list) Output: ['d', 'b', 'c', 'a']
1 ответ
+ 1
I don't think there is any built in swap function in python but
list [0], list [3] = list [3], list [0] should work