Add count until certain value then reset to zero python

Question:

I am trying to change the value of x depending on the length of my list

How can x count up by 5 through each iteration and then back to 0 after the 10th round?

list = {"one", "two".....fifty} #example shortened 
listLen = len(list) # 50

for i in range (0, listLen) # 0 - 49

    x = ??? # +5 max 45 
    
    ops.update(location=x)

Desired outcome:

0. x = 0
1. x = 5
2. x = 10
...
9. x = 45

10. x = 0
11. x = 5
12. x = 10
...
19. x = 45
...



(0,5,10,15,20,25,30,25,40,45,0,5,10,15,20,25,30,25,40,45            
 0,5,10,15,20,25,30,25,40,45,0,5,10,15,20,25,30,25,40,45
 0,5,10,15,20,25,30,25,40,45) 
Asked By: luke jon

||

Answers:

Try this:

ans = []
for i in range (0, listLen): # 0 - 49
    x += 5
    ans.append(x)
    if i % 9 == 0:
        x = 0
Answered By: rockzxm

Try this

outcome = []
lst = {1,2,3,...,50}
lstLen = range(0, len(lst), 5)

for a in range(len(lst)):
  outcome.append(lstLen[a%10])

print(outcome)

Output

[0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45,
 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 
0, 5, 10, 15, 20, 25, 30, 35, 40, 45]
Answered By: codester_09
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.