Question

TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

Could somebody tell me what this error means please.

Was it helpful?

Solution

It means that you have done e.g.

a = b - c

but, although b is an int, c is None and therefore the subtraction operation cannot happen.

As to the root cause, it is most likely that at some point c = some_function() and there is a path through some_function that will (implicitly or explicitly) return None.

OTHER TIPS

TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

From the error mentioned above it is clear that you are performing some kind of operation on data which is having data-type different. One is int and other is None.

This means you can not perform specific operation on the two operands having different data-types.

It is similar to : adding two mangoes into 3 banana and the result is unknown.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top