photo of man walking near LED signage
Photo by Ryoji Iwata on Unsplash

Since you don’t have a predefined type for a variable in Python, you may notice a lot of bugs that can arise. As such, it is very important that you pay a lot of attention in cases when you have to make sure that you are using the correct type of variable.

This can also be the case when you expect a variable to be a number, but you get a string or any other type instead.

Let us assume that you have a scenario when you do not have any specific number type to deal with, but you want to make sure that it is a number. To do so, we are going to use _Number_ from the _numbers_ module.

Let us assume that we have the following variables and we want to check whether they represent numbers.

The first variable is obviously a string, so it is expected to return False. The second variable is a number, so it is expected to return a True. The third variable is a float, so it is expected to return a True.


This can be useful when you want to make sure that you are using the correct type of variable and do not want to use multiple checks on whether the given variable is a float, or an integer.

I hope you find it useful.