Answers for "swap first and last element in list python"

1

swap first and last element in list python

#sample_list = [1,2,3,4]
sample_list[0], sample_list[-1] = sample_list[-1], sample_list[0]
#returns sample_list = [4,2,3,1]
Posted by: Guest on August-09-2021

Code answers related to "swap first and last element in list python"

Python Answers by Framework

Browse Popular Code Answers by Language