I'm working with creating excel sheets using python. I'm trying to use a nested for loop to fill in some cells on a spreadsheet and it's not going well. What I want it to do is for each row in a given list of rows I want it to enter an even number into the cell. So basically it should look something like this: 2 4 6 8 etc. (One value per cell)
but instead it comes out like: 24 24 24 24
All the cells have the same value.
Aside from the obvious formatting issues (I'm not finished with the formatting part), it prints the last number in the nested loop for every single cell. From my testing it it appears to be fully executing the inner loop for every cell. I'm using XlsWriter if that helps. I'm not sure how to get it to stop.I'm guessing it's pretty obvious but I haven't done any actual "programming" in years so the solution is eluding me. Here's the loop in question:
for items in purple_rows:
riser_cable.write(items,0,'Company Name',format8)
riser_cable.write(items,1,None,format8)
riser_cable.write(items,2,None,format8)
riser_cable.write(items,3,'Riser',format8)
for i in range(2,26,2):
riser_cable.write(items,4,i,format8)
print(i)
The last 3 lines are ones causing problems. Thanks for the help!
Edit: The sheet should look like this https://i.sstatic.net/RGXbg.jpg but the code presently turns the entire "Port" column to 24.