-1

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

esqew
  • 42,425
  • 27
  • 92
  • 132
xamcx
  • 21
  • 5

1 Answers1

2

Try the modulo operator "%" combined with a conditional:

for x in range(101):
    if x%25 == 0:
        print(x)
SquatLicense
  • 188
  • 8