What is the equivalent of the following in python?
for (i=0; i<n; i++) for (j=i+1; j<n; j++)
Or in a sense the following. He must also remove an element from A at the end of each round of the cycle.
for a in A: for a' in A/{a}: #ie rest of the elements of A #do something with a,a'
Is there a pythonic way to do this without using enumerate ()?
Changes:
Sorry for the poor description.
In the first example, I want to use i and j only as indices. Their values ββdo not matter. Its just the crude equivalent of C ++ of the latter.
The outer loop runs n times. The inner loop executes (n-1), (n-2) ... 0 times for each iteration of the outer loop.
Maybe this might help (pseudo code):
function next_iteration(list): head = first element tail = remaining elements #list each element in tail interacts with head one by one next_iteration(tail)
PS: All of the above code examples are pseudo-codes. I'm trying to express something that is still a little vague in my mind.
source share