 # isnumeric Python Implementation with Examples

### GET FREE AMZAON AUDIOBOOKS      Python has many inbuilt functions that allow you to manipulate and find something from the input. The python isnumeric() function is one of them. It allows you to find whether a string contains numeric values or not. It will return true if all the character inside the string is numeric and returns false if the string contains an only string or combination of alphabets and number. In this entire tutorial, you will learn how to implement the python is numeric() method with various examples.

## Examples of python isnumeric method

In this section, you will learn all the examples of isnumeric() method. All the examples have been done on Jupyter notebook. You can use your own python interpreter.

### Example 1 Applying isnumeric() on numeric characters

Let’s apply python isnumeric() on text with all numeric characters.

``````text = "12345"
print(text.isnumeric())``````

Output

You can see the output is True. The text.isnumeric() has checked all the string characters one by one and returned true when it has not found any characters other than numbers.

### Example 2: Applying python isnumeric() on alphabets

Now let’s apply isnumeric() method on a string that contains only alphabets.  Execute the below lines of code.

``````text = "ABCDEFabcdef"
print(text.isnumeric())``````

Output

This time the isnumeric() has returned False as all the characters inside the string are alphabet.

### Example 3: Applying isnumeric on the combination of character

Now let’s apply isnumeric() function on strings that contains both alphabets and numeric characters.  Just run the below lines of code and see the output.

``````text = "ABCDEF12345"
print(text.isnumeric())``````

Output

You can see the output is False as the string contains both numeric and alphabets characters. The function could return True when all the characters will be of numbers.

## Conclusion

These are the basic examples for applying the python isnumeric() method. However, you can use this method for other purposes also. For example, you want to check records of a pandas dataframe is numeric or not. Thus very helpful in the categorization of the dataset. I hope you have liked this tutorial. If you have any doubt then you can contact us for more help.

Source:

Python documentation 