Get data type in Python

Contrary to other programming languages, such as C++ or Java, you don’t specify the data type when defining a variable in Python, but it doesn’t mean that the variable doesn’t have a type.

You can check the variable type using the type function that returns the type of data.

Here’s how it works:

This code returns this result:

You can also check types of data structures. Here’s is an example of a list, dictionary, and tuple.

The result: