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\']
Solution for your query :
def shift(aList): l = list() n = len(aList) l.append(aList[-1]) temp = aList[:n-1] for i in temp: l.append(i) return l print(shift(aList=[1,2,3]))