+ 1
[1,2,3,4,5]->[5,4,3,2,1](we have to reverse the digits )
can anyone try better than me? a=[1,2,3,4,5] for i in range(len(a)//2): temp=a[0+i] a[0+i]=a[-1-i] a[-1-i]=temp print(a)
6 Answers
+ 2
Thanks
+ 1
lst=[1, 2, 3, 4, 5]
print(lst[::-1]
It's simple. And one liner
0
print(reversed(a))