+ 5
What you're doing here is called Parallel assignment. It allows you to assign the values in an iterable to a list  (or tuple) of variables in a single and elegant statement. This means each item in the list is assigned to the variables respectively. Since s[::-1] returns the reverse of the original list, we can say something like this >>>a,b,c = [0,2,1] Here, a = 0,b = 2, c = 1(parallel assignment) So, s[a] means s[0] which is 1
22nd Feb 2022, 4:31 AM
Simba
Simba - avatar