"
This article is part of in the series
Published: Wednesday 12th April 2017
Last Updated: Tuesday 11th April 2017

This beginner's Python tutorial will teach you the basics of how to check for an object type in Python. As you probably already know, different types of objects in Python. Objects can be lists, strings, integers, etc. There may be times in your career as a developer where you need to know the difference between one type or another, because it isn't always obvious to the naked eye. If you ever find yourself needing to find out what type of an object you're working with, Python has a built-in functioning for determining that. The type() function, as it's so appropriately called, is really simple to use and will help you quickly figure out what type of Python objects you're working with.

To use it, you just need to pass the object through the function as a parameter and you'll quickly get your answer. For example, if you're looking to find the type of an object that looks like this:

one = ['purple', 'yellow', 'green']

You'll just need to use the type() function, like this:

type(one)

You may already know the answer because of how the object is formatted (any objects between two [] brackets is a list), but your output will be this:

<type 'list'>

You can also use the type() slightly differently, using the following syntax:

type(one) is a list
>>>True

In the example above, the first line is how you'd use the type() function and the second line is the output that tells you if the object is the type you think or not (in this case, it is in fact a list). Using the type() function in Python is a straightforward and relatively easy way to determine what type of objects you're working with, so play around with it until you would feel comfortable using it in any coding situation.