Measuring the length of a list with a missing cell

For the row that has a missing value, I first printed its length and it gave me the correct length which was 12.
I then wrote something in the missing cell and even though I deleted it, instead of giving the length as 12, it now says 13 with the last cell printed as an empty cell.

Any idea why this is happening?

Hi @mohamedelauzei,

You can remove the last empty item of the list by using google_apps_data[10473].pop(). Then find the length again, it should be correct now.

Hi Elena

Thank you very much for your response. Yes I know I could do that. I was just wondering why python was treating the excel cell as an empty string instead of just not counting it as it was blank.

After that you manually inserted and removed that value, if you open this file again using Notebook instead of Excel, you will see an extra comma at the end of the edited line. This makes appearing an empty string while reading the file. Just remove the comma, save the file and re-read it.

Awesome! Thanks a lot, Elena.

1 Like