Answers for "python swap two values in list"

1

python swap two values in list

a_list = ["a", "b", "c"]
a_list[0], a_list[2] = a_list[2], a_list[0]
print(a_list) # ["c", "b", "a"]
Posted by: Guest on October-14-2021

Python Answers by Framework

Browse Popular Code Answers by Language