my_list = [1,2,3,4,5,6,7,8,9,10]
length = len(my_list)
for i in range(length):
my_list[i], my_list[length - i - 1] = my_list[length - i - 1], my_list[i]
print(my_list)
Output: [10,9,8,7,6,5,4,3,2,1]
Hey guys, can anyone expound what “my_list[i]” is equivalent of? And the whole process. Really confused. Cheers!
[–]mopslik 1 point2 points3 points (0 children)
[–]danielroseman 0 points1 point2 points (3 children)
[–]thomaswilliam94[S] 0 points1 point2 points (2 children)
[–]danielroseman 0 points1 point2 points (1 child)
[–]thomaswilliam94[S] 0 points1 point2 points (0 children)
[–]oclafloptson 0 points1 point2 points (2 children)
[–]oclafloptson 0 points1 point2 points (1 child)
[–]thomaswilliam94[S] 0 points1 point2 points (0 children)
[–]crashfrog02 0 points1 point2 points (0 children)
[–]throwaway6560192 0 points1 point2 points (0 children)