Python code: TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

hi, I am new to Python at beginner level and following Mr Mosh tutorials.
while I am following Mr Mosh coding a simple project that involves automation that process thousands of spreadsheets in under a second, and do act in accordance with him step by step. Although the codes mine and his are the same but when I run the code I am getting something like:

corrected_price = cell.value * 0.9
TypeError: unsupported operand type(s) for *: ‘NoneType’ and ‘float’

can anyone help me with this part please

have you tried:
corrected_price = float(cell.value) * 0.9

The error indicates that you try to multiply a None type with a float which makes no sense mathematically. perhaps you should check the cell to see if it’s empty.

thanks a lot for your kind replays but still having the same problem despite trying all the answers you gave me

Could you share what your code looks like now and what error you are currently getting?

If you have applied all of the instructions, I assume it would look something like this:

if cell.value:
  corrected_price = cell.value * 0.9
else:
  corrected_price = 0

I assume that the value should be presumed to be 0 if not present, but I do not own the Python course so I am not certain what the behavior should be for an empty cell.

Please i am having similar issues how do i go about it

Hi, try checking your range in your fir statement. It should be like this.
For row in range(2,sheet.max_row +1):

yeah I had same problem and the fix was this:
Since I created the excel sheet in google sheets, the max rows were 1000.
So to fix the error, I simply added 0 (zero) to all the rows below the 4 rows ( all 1000 of them ) with 0 data and then re-imported back into Python.
Or you could simply delete the rows 5-1000 in google sheet, download and re-upload into Python.
This resolved it.