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

Instruction

Okay, you've seen that printing each row resulted in a tuple of cells. How can we access a given cell, and more importantly, the value it contains? We have to add an inner loop, so we can iterate directly over each row"s cells:

for row in worksheet["A1":"D6"]:
  for cell in row:
    print(cell.value)

In the outer loop, we iterate through all possible rows. In the inner loop, we access each element in a given row, or each particular cell.

Exercise

Okay, let's iterate over a spreadsheet containing a small table that indicates whether a given day was a workout day or not, as indicated by the sample below:

workouts

Your job is to find the total number of workout days. Each workout day is indicated with a "+" inside a cell. Create the workout_days_number variable and save the final result to it. Print the result. The whole table spans from A1 to E20.

Stuck? Here's a hint!

Iterate over every row and every cell. If the cell value equals +, add 1 to the workout_days_number variable.