How to Check Type in Python
To check the type in Python, you can use the type() function.
The following example shows how to check the type in Python using the type() function.
Using type() Function
We can use the type() function to check the type of a variable.
Suppose we have the following variable:
# Declare variable
x = 10
# Check the type of the variable using the type() function
print(type(x))
Output: 👇️
<class 'int'>
In this example, we use the type() function to check the type of the variable x. The output shows that the data type of x is an integer.
Conclusion
We can use the type() function to check the type in Python.