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\']
This could be done simply by using list method: insert,
values = [2, 3, 5, 7, 11, 13] def shift(list): new_list = [] for i in list: new_list.insert(len(new_list)-1, i) return new_list
print(shift(values))
Output is:
[3, 5, 7, 11, 13, 2]