-2

What function do you use to check what kind of datatype your variable or parameter

2 Answers2

1

In Python, the recommended way is to do it with isinstance(), so to see the type of var:

isinstance(var, str)

Alternatively, you can do it with type():

type(var)   

Using the second way, in a more specific context, if you want to know if var is a string, you can do it this way:

type(var) == str
Dennis Kozevnikoff
  • 2,078
  • 3
  • 19
  • 29
0

Use the type() function. For example

type("foo")

will output <class 'str'>