I want to do a for loop and explain it here by simple print function. I want change the data printed after a fixed value. Let's regard this code:
for i in range (7):
print (i, i+15, i+1)
it gives me:
0 15 1
1 16 2
2 17 3
3 18 4
4 19 5
5 20 6
6 21 7
But I want to add 1 to the printed values of the second row after each 3 interation. I mean from the first to third iteration, I want the same results as printed above. But from third to sixth I want to add 1 to i+15 (printing i+16 rather than i+15). Then again after the sixth row, I want to add 1 to i+16 (printing i+17 rather than i+16 or i+15). I mean I want to have this one:
0 15 1
1 16 2
2 17 3
3 19 4
4 20 5
5 21 6
6 23 7
How can I make my i in the function to e such a thing? Itried the following but it gives another thing:
for i in range (7):
if i % 3 == 0:
print (i, i+15+1, i+1)
else:
print (i, i+15, i+1)
I do appreciate any help in advance.
print(i, i + 15 + i // 3)- is this what you are looking for? Noifs needed