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?
You'll need a while loop for this:
i = 0
while i < len(myArray):
# do stuff
if special_case: i+= 1
i += 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With