Instruction
Excellent! In openpyxl, we mainly operate on data row by row. Writing data cell by cell can be pretty tedious and tiresome. If we know the number of columns, we can create a list of the values we want to add:
new_row = ["21:00", "Cinema"]
Then we can use the append method to add the data to the selected worksheet:
ws.append(new_row)
The data from this list will be added after the existing rows.
Exercise
We've already selected the Entertainment worksheet for you. Right now, there's only one row of information:
| Time | Event |
|---|
Create two lists with two rows and append them to the worksheet using the append method:
- The first row should contain
"16:30"and"Groceries". - The second row should contain
"20:00"and"Party".
Save the workbook in the file budget.xlsx.



