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

**URL:** <https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271>\
**Category:** Python\
**Created:** [June 24, 2022, 11:28am UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271 "2022-06-24T11:28:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jahan](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jahan](https://forum.codewithmosh.com/u/Jahan)\
**Post date:** [June 24, 2022, 11:28am UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271/1 "2022-06-24T11:28:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![svenne](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@svenne](https://forum.codewithmosh.com/u/svenne)\
**Post date:** [June 26, 2022, 2:56pm UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271/2 "2022-06-26T14:56:02Z")

</div>

have you tried:  
corrected\_price = float(cell.value) \* 0.9

---

<div class="post-metadata">

**Author:** ![JohnLu](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JohnLu](https://forum.codewithmosh.com/u/JohnLu)\
**Post date:** [June 27, 2022, 3:06am UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271/3 "2022-06-27T03:06:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jahan](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jahan](https://forum.codewithmosh.com/u/Jahan)\
**Post date:** [July 3, 2022, 1:37pm UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271/4 "2022-07-03T13:37:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [July 3, 2022, 6:52pm UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271/5 "2022-07-03T18:52:04Z")

</div>

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:

```python
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.

---

<div class="post-metadata">

**Author:** ![Jennyyoung](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jennyyoung](https://forum.codewithmosh.com/u/Jennyyoung)\
**Post date:** [January 26, 2023, 3:29pm UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271/7 "2023-01-26T15:29:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Yanga](https://avatars.discourse-cdn.com/v4/letter/y/eada6e/32.png) [@Yanga](https://forum.codewithmosh.com/u/Yanga)\
**Post date:** [February 4, 2023, 12:44pm UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271/8 "2023-02-04T12:44:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tabufx50](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/tabufx50/32/8247_2.png) [@tabufx50](https://forum.codewithmosh.com/u/tabufx50)\
**Post date:** [May 20, 2024, 3:09pm UTC](https://forum.codewithmosh.com/t/python-code-typeerror-unsupported-operand-type-s-for-nonetype-and-float/13271/9 "2024-05-20T15:09:35Z")

</div>

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.
