import math def deverseHanshu(*nums): listA=list(nums) for i in range(0,math.ceil(len(listA)/2)): #math.ceil(3.14) #4 c=listA[-(i+1)] listA[-(i+1)]=listA[i] listA[i]=c return listA print(deverseHanshu(45,3,89,45,56,2,22,10)) #方法2 def getReverse(listAttr): resultList=[] for i in range(len(listAttr)-1,-1,-1): #倒序 resultList.append(listAttr[i]) return resultList listA=[12,23,45,32,16] print(getReverse(listA))