👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.

How to switch array list in Python?

The simplest way to switch two lists in Python is to use a third temporary list (C in the following example):

# Create lists A and B
A = [1,2,3,4]
B = ['a', 'b', 'c']

# Switch lists A and B (A <=> B)
C = A
A = B
B = C

The following displays the whitched lists:

>>> print (A, B)
['a', 'b', 'c'] [1, 2, 3, 4]