Trying to understand the double index in python
The second index does the same as the first but with the nested value.
a = [(1, 2), (2, 3), (3, 4)] a[-1] # (3, 4) a[-1] # 4
In your example you dont have a list with numbers but enumerate objects converted to lists
It means that you have data like this:
nums = [1, 2, 3, 4, 5] enum_list = list(enumerate(nums)) # [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5)]
It seems like
left is an array containing tuples. I.e. Each element of the array is a tuple.
In this case
left[-1] would reference the first value in the last element of the array (
I found this by running your code and printing the value of
left just before your code calls
left[-1]. This way you can see what data type left is.