Respuesta :
my_lst = ([1,2,3,4,5,6])
h = my_lst[0]
my_lst[0] = my_lst[-1]
my_lst[-1] = h
print(my_lst)
The code that swaps the first and last elements in a list called my_list is as follows:
my_list = ["break", 14, 15, "john", "black"]
my_list[0], my_list[-1] = my_list[-1], my_list[0]
print(my_list)
Code explanation:
The code is written in python.
- The first code, we declared a variable named my_list. This variable is a list. The list have values of different data type.
- The second line we have to swap the first value in the list with the last value in the list.
- Finally, we print our new swapped list .
learn more on python list here: https://brainly.com/question/26104476
