W3docs

How to determine a Python variable's type?

In Python, you can determine the type of a variable by using the type() function.

In Python, you can determine the type of a variable by using the type() function. For example:

Determining the type of a variable by using the type function in Python

python— editable, runs on the server
Info

Watch a video course: Python - The Practical Guide

You can also use the isinstance() function to check if a variable is an instance of a particular type. For example:

Determining the type of a variable by using the isinstance function in Python

python— editable, runs on the server