Detect type of input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Detect type of input

How to detect type of input like str or int in python? To tell if it True or False

22nd Oct 2018, 3:51 PM
Tan Vireak Punhakvorn
Tan Vireak Punhakvorn - avatar
2 Answers
+ 2
input always returns a string
22nd Oct 2018, 4:27 PM
jtrh
jtrh - avatar
+ 1
you can use type(var) to get its type, then chect the result if it's int or str
22nd Oct 2018, 4:27 PM
Taste
Taste - avatar