Computer Science, asked by shijijobkp, 12 hours ago

WAP THAT ASK USER TO ENTER DIFFERENT NOS IN A LIST AND SWAP(INTERCHANGE) THEM

Answers

Answered by khushi89204
1

\huge\star\mathfrak\blue{{HeyMate...!!}}

Swap elements by value in a list:

︎︎︎a_list = ["a", "b", "c"]

︎︎︎index1 = a_list. index("a")

︎︎︎index2 = a_list. index("c")

︎︎︎a_list[index1], a_list[index2] = a_list[index2],

︎︎︎a_list[index1]

︎︎︎print(a_list)

Similar questions