Explanaation:
๐ข Line 1: 5
5
5 is an integer (int).
So Python knows this is a numeric value.
๐ก Line 2: None
None
None is a special Python value representing no value / absence of a value.
Its type is:
type(None)
Output:
<class 'NoneType'>
๐ต Line 3: 5 + None
Python now tries to perform:
5 + None
The + operator can add compatible numeric values such as:
5 + 3
But None is not a number.
Python cannot perform:
int + NoneType
So the operation fails.
๐ด What Error Occurs?
Python raises:
TypeError
Because the two operands have incompatible types.
The actual error message is similar to:
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
Final Ouptut:
Type Error

0 Comments:
Post a Comment