swap first and last element in list python

Solutions on MaxInterview for swap first and last element in list python by the best coders in the world

showing results for - "swap first and last element in list python"
Marilou
10 Jan 2018
1#sample_list = [1,2,3,4]
2sample_list[0], sample_list[-1] = sample_list[-1], sample_list[0]
3#returns sample_list = [4,2,3,1]