I want to rotate elements in a list, e.g. - shift the list elements to the right so [\'a\',\'b\',\'c\',\'d\'] would become [\'d\',\'a\',\'b\',\'c\'], o
[\'a\',\'b\',\'c\',\'d\']
[\'d\',\'a\',\'b\',\'c\']
you can use roll function from numpy.
>>> import numpy as np >>> q = [1, 2, 3, 4, 5] >>> np.roll(q, 2) array([4, 5, 1, 2, 3])
Hope it helps!