Teamware Solutions processes ordered items in Python lists and occasionally needs to exchange two positions without creating a second list. Implement a function that swaps the elements at two provided indices in place and returns the modified list.
Implement swap_elements(arr, index1, index2).
arr, a list of integers, and two valid zero-based integer indices, index1 and index2.index1 and index2 have been exchanged.def swap_elements(arr, index1, index2):