isinstance()
The function isinstance() accepts two parameters. One is a value and the other is a data type. It then checks if the value passed is of the given data type. Let's see how it works.
PYTHON
1print(isinstance(6, int))
2print(isinstance(6, str))
3print(isinstance(3j, complex))The output will be:
PYTHON
1True
2False
3Truexxxxxxxxxxprint(isinstance(6, int))print(isinstance(6, str))print(isinstance(complex(1, 2), complex))OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment


