Write a program to swap first and last elements in a list


Topic: Write a program to swap first and last elements in a list

Solution

my_list = [1, 2, 3, 4, 5, 6]
my_list[0], my_list[-1] = my_list[-1], my_list[0]



List all Python Programs