HOW TO CHECK DATA TYPE IN PYTHON

In Python, every value has a datatype. Everything is an object in Python programming, and data types are classes and variables are instance (object) of these classes.
To check the data type in Python, we can use the type() inbuilt method. This returns the class type of the argument(object) passed as a parameter.
str = 'Pythonpoint' print(type(str)) int = 12 print(type(int)) float = 2.9 print(type(float)) li = [1,2,3] print(type(li)) d = {1:'one', 2:'two'} print(type(d)) t = (1, 2, 3) print(type(t))
Output:
<class 'str'> <class 'int'> <class 'float'> <class 'list'> <class 'dict'> <class 'tuple'>
Subscribe
Login
Please login to comment
0 Discussion