I have a list something like:
[[16777230, 0], [16777226, 1], [16777252, 2], [16777246, 0]]
I want to make a loop inside a loop(nested loop) for my operation in python such that the inner loop will always start from the next element of the outer loop.
For e.g., the outer loop will traverse all the elements of the list from index 0 to 3 in each iteration. But the inner loop will start from index 1 and end at index 3 in the first iteration of the outer loop. Then, in the second iteration of the outer loop, the inner loop should traverse index 2 to index 3. And so on... The last iteration of the outer loop should make the inner loop traverse from index n to index n, basically only the last element, in this case index 3 to index 3.
The problem is I am deleting the elements of list while I traverse. So, it is creating issues like list index out of range while using range function to traverse.
How to construct these inner and outer loops?
I tried this, but doesn't seem to work:
for sub_list1 in yx:
index_sl1 = yx.index(sub_list1)
for sub_list2 in yx[index_sl1+1:]:
Operations...
Help would be appreciated. Thank you!!