Hi,
I want to change an item from one value to another. How would I do this?
for example, because your title was 'swap' items in a list:
a_list = [1,2,4,3]
print(a_list)
tmp = a_list[2]
a_list[2] = a_list[3]
a_list[3] = tmp
print(a_list)
Of course for this particular example you could also have just said a_list.sort()
to get the same effect as lines 3,4,5
This is double thread see Gribouillis answer in other thread.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.