Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close


Good job! We can also use the max_row and max_column properties to iterate over the whole spreadsheet with the help of the iter_rows() method:

for row in sweets_ws.iter_rows(max_col=sweets_max_col, max_row=sweets_max_row): 
  for cell in row: 

The iter_rows() method uses the max_col and max_row parameters to delimit the area of data lookup. It can also use the min_col and min_row parameters, which we haven't discussed. But you've probably figured out that these parameters let the user define their desired minimum column and row values for a lookup.


Load the january_diet.xlsx file. In the active worksheet, count the number of days in which exercises were performed. Consider only the days after the first week of January (start with the row number 9). Save the result to the days variable and print its value. Here are the arguments you should use in the .iter_rows() function:

  • max_column should equal the maximum available column.
  • max_row should equal the maximum available row.
  • You should start searching for pluses from column number 2.
  • You should start searching for pluses from row number 9.

Here's a reminder of what the worksheet looks like:


Stuck? Here's a hint!

Set the days variable to 0. Then search each row for a plus sign. If you find any plus sign in the row, add 1 to the days variable. Print the days variable.