实现列表的逆序
def reverse(list):
for i in range(0,len(list)//2):
temp = list[i]
list[i] = list[-i-1]
list[-i-1] = temp
l= [2,6,8,9,13,7]
reverse(l)
print(l)
[7, 13, 9, 8, 6, 2]
Process finished with exit code 0
实现列表的逆序
def reverse(list):
for i in range(0,len(list)//2):
temp = list[i]
list[i] = list[-i-1]
list[-i-1] = temp
l= [2,6,8,9,13,7]
reverse(l)
print(l)
[7, 13, 9, 8, 6, 2]
Process finished with exit code 0