a = [1,3,6,8,9]
print("通过下标逆序遍历1:")
for i in a[::-1]:
print(i, end=" ")
print("\n通过下标逆序遍历2:")
for i in range(len(a)-1,-1,-1):
print(a[i], end=" ")
print("\n通过reversed逆序遍历:")
for i in reversed(a):
print(i, end=" ")
python 倒序遍历-三种方法
最新推荐文章于 2025-03-15 10:42:19 发布