Check out example codes for "swap two elements in a list python". It will help you in understanding the concepts better.

Code Example 1

i = ['title', 'email', 'password2', 'password1', 'first_name', 
         'last_name', 'next', 'newsletter']
    a, b = i.index('password2'), i.index('password1')
    i[b], i[a] = i[a], i[b]

Learn ReactJs, React Native from akashmittal.com