I'm trying to increment a for loop within itself if a certain condition is met, as shown in the code below
for i in range(0,5):
if condition == True:
i+=1
print(i)
If it runs as I want it to, the output should be: "1 3 5". Instead, the output is "0 1 2 3 4". Can anyone help me with this?
conditionis never True. It's always helpful to create an example that people can actually run.continuestatement when the condition isFalse. Otherwisewhileis the way to go as others have already stated