How to write multiple variables for loop in python. I have one variable i
start at the beginning and j
starting from the end. It should iterate till i <= j.
What's the equivalent code in python.
for (int i = 0,j=len-1; i <= j; i ,j--){
// some code
}
CodePudding user response:
A trick is using while-loop:
i, j = 0, len - 1
while i <= j:
# some code
i = 1
j -= 1
CodePudding user response:
for j in range(len-1,0-1):
i=0
while(i<=j):
i =1
This may work