let's say I have a loop that run over a list that contains numbers from 1 to 100 ( 100 element ), and I want to print i ( i is element in list for i in list:
) every 25th time the loop runs so it after running it prints :
25
50
75
100
Asked
Active
Viewed 71 times
1 Answers
2
Try the modulo operator "%" combined with a conditional:
for x in range(101):
if x%25 == 0:
print(x)

SquatLicense
- 188
- 8