代码:
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
m = int(input('请输入后移的位置数:'))
front_list = []
for i in range(m, 0, -1):
front_list.append(array.pop(-i))
front_list.extend(array)
array = front_list
print(f'后移了{m}个位置的列表为:{array}')
运行结果: