-2

Does Python have the function like JavaScript?

typeof variable

2 Answers2

0

Try type()

>>> number = 1
>>> type(number)
<class 'int'>
>>> text = "Hello"
>>> type(text)
<class 'str'>
>>> arr = [1,2,3]
>>> type(arr)
<class 'list'>

Nishan Paudel
  • 125
  • 10
0

You simply type

type(var)

or if you want to display it too, then use this:

print(type(var))