In python, you can access the last element of a list implicitly using an index -1. So, it a[-1]will return the value of the last element of the list a.
By executing a for loop for a[-1] in a, you iterate over the list and store the value of the next element ain your last element.
, , , :
a=[1, 'a', 2, 'b', 'test', 'exam']
for a[-1] in a:
print(a)
:
[1, 'a', 2, 'b', 'test', 1]
[1, 'a', 2, 'b', 'test', 'a']
[1, 'a', 2, 'b', 'test', 2]
[1, 'a', 2, 'b', 'test', 'b']
[1, 'a', 2, 'b', 'test', 'test']
[1, 'a', 2, 'b', 'test', 'test']
, , , 'exam', .
, .