Skip to content
Advertisement

Python count up by 5 after each iteration in for loop

I am trying to open a csv file in python and read the rows into a list.

The list is then sent to a function where I want to add 5 to the value of x after each iteration with the value of d going up by 10 after every 10th iteration.

d I have working but can’t quite figure out x. Please can someone help me understand where I am going wrong with my math. I thought setting x = 0 outside the loop and then x+=5 inside would do it.

JavaScript

Advertisement

Answer

It looks like you’re looking for some fairly simple math on the loop counter:

JavaScript

Output (for a 24-entry listGroup):

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement