Python Program to Swap Two Elements in a List
In this article, we will explore various methods to swap two elements in a list in Python. The simplest way to do is by using multiple assignment.Example:Pythona = [10, 20, 30, 40, 50] # Swapping elements at index 0 and 4 # using multiple assignment a[0], a[4] = a[4], a[0] print(a)Output[50, 20, 30,