Main Tutorials

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()

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments