【发布时间】:2020-06-12 05:40:51
【问题描述】:
我正在尝试使用以下函数来旋转数组:
def rotLeft(a,d):
temp=[]
temp.append(a[0:-1])
temp.insert(0,a[-1])
return temp
我应该得到输出为 5 1 2 3 4
但我得到 5,[1,2,3,4]
如何解决这个问题
【问题讨论】:
-
什么是
d?在你的 fnc 中 -
不需要
temp,只需return a[-1:] + a[0:-1]
标签: python arrays python-3.x list