Lists in python - unexpected results, need some explanation how

countries = [“USA”, “Canada”, “India”]
countries[0], countries[1] = countries[1], countries[0]
print(countries)

I don’t understand how line number 2 changes the list to result in [“Canada”, “USA”, India"]

Hello Vivek,

here at line number 2 you are assigning the values countries[1] to countries[0]
countries[0], countries[1] = countries[1], countries[0]

and value of countries[0] to countries[1]
countries[0], countries[1] = countries[1], countries[0]

so here the value of these are changed at their address location and when you print them the newly updated value is reflected