Python type error














































Python type error



                                                 Python TypeError          
Python TypeError is an error generated by python when we perform operation of a wrong data type of an object.  For example, try to perform sum operation on integer with a string. TypeError also occurs when we perform a operation of on an object and the object does not support the operation.

The most common causes for raising TypeError are:
1)Performing unsupported operation between two different data types.
Ex: adding string to an integer.

2)Calling an identifier which can not be called.
Ex: calling a normal variable (not a function/method).

3)Trying to iterate through an identifier which is not iterable.
Ex: Trying to iterate through an integer.

4)Using incorrect data type of list index:
Ex: using string as an index of a list instead of using integer.


This TypeError can be avoided/solved by using Try and Exception handling.  

Comments