JoshKopen :
I'm trying to run a python program with a for loop which has a variable i increased by 1 every time from 1 to the length of my list. In java, my code that I'm going for might look something like this:
for (int i = 0; i < array.length; i++) {
//code goes here
i += //the number i want it to go up by
}
This actually affects my counter the way intended and allows me to effectively skip numbers in my for loop and I want to try to run a similar program but in python. Is there any way to do this with python's built in functionality or do I have to just use a while loop and a counter to simulate this myself if I want python to work this way?
inspectorG4dget :
You'll need a while loop for this:
i = 0
while i < len(myArray):
# do stuff
if special_case: i+= 1
i += 1
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=460952&siteId=1