Python – How to check the variable’s type?

In Python, we can use type() to check the variable’s type.


num = "3.141592653589793238"

print(type(num))

pi = float(num)

print(type(pi))

Output


<class 'str'>
<class 'float'>

References

  1. Python docs – type()

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments