Search code examples
pythonfor-loopgoogle-slides-apigoogle-slides

Loop through a Google slides Table's cell with python


I am using the Slides API to establish the format of some table cells. My table is 5 rows x 3 columns. These are 0-indexed. I do not need to do any formatting on any of the cells of the first column, so my starting point has to be (0, 1).

The specific API request I'm using is updateTextStyle

updateTextStyle is an object with a cellLocation property, which in turn is a tableCellLocation object

Normally, I'd use a double for loop with i being rows and j being cols, however, since Python has no countable iteration (as far as I know), I don't know of a way to start looping from the 1 col index.

The object looks like this:

{
  "rowIndex": integer,
  "columnIndex": integer
}

So, how do I iterate through a number from a starting point and with a defined ending point as well?


Solution

  • You can achieve this using range function

    for i in range(start_i, end_i-1):
       for j in range(start_j, end_j-1):
          pass # do stuff here