for x in 100: #what to do every time (100 times): replace this line with your every-iteration functions. if x % 5 == 0: #what to do every 5th time: replace this line with your nth-iteration functions.