Python is () function of detecting the type of the variable can be compared directly by type name type.
= {34234 the_input } X = type (the_input) # X type type IF X == int: # Available == comparing Print ( ' int ' ) elif X is STR: # can also be compared is Print ( " Character string " ) elif X == list: Print ( " list " ) the else : Print (X) # <class 'SET'>
In addition, we can see int, str, list variables such as type is Python reserved words, try not to variable names.