In This Article You Will Learn About Python String Method isdigit(), isidentifier(), islower(), isnumeric() and isprintable()
Python String Method – Before moving ahead, let’s know a little bit about methods index(), isalnum(), isdecimal()
isdigit() method – It returns True if all the characters are digits, otherwise False.
Syntax - string.isdigit() Parameter Values - No parameters.
Note: It considered exponent powers as digit.
Example 1- Check if all the characters in the given string are digits.
x = '56427' y = x.isdigit() print(y)

Example 2- Check if all the characters in the given string are digits.
x = '6829yeuk' y = x.isdigit() print(y)

Digit type – It contains two types of digit which includes numeric type = digit and numeric type = decimal.
Note: – Isdigit() method gives False if we use fraction and roman numerals.
isidentifier() method – It returns True if the string is a valid identifier, otherwise False.
Valid identifier – A string is considered as a valid identifier if it contains only letter (a-z), numbers (0-9) and underscore(_). A valid identifier cannot start with a number, or contain any spaces.
Syntax - string.isidentifier() Parameter Values - No parameters.
Example 1- Check if the string is valid identifier.
x = 'Hello,Python' z = x.isidentifier() print(z)

Example 2- Check if the string is valid identifier.
x = 'Hello,Python' z = 'code no. 65' y = 'Hello Python' v = '5five' b = ' Python' c = 'hello' n = 'five5' print(x.isidentifier()) print(z.isidentifier()) print(y.isidentifier()) print(v.isidentifier()) print(b.isidentifier()) print(c.isidentifier()) print(n.isidentifier())

islower() method – It returns True if all the characters are in lower case, otherwise False.
Syntax - string.lower() Parameter Values - No parameters value.
Example 1- Check if all characters of string is in lower case.
x = 'hello, python' z = 'HELLO, PYTHON' print(x.islower()) print(z.islower())

Note: – islower() method doesn’t convert numbers, symbols and space into lower case.
Example 2- Check if all characters of string is in lower case.
x = '1234' z = '&#' print(x.islower()) print(z.islower())

isnumeric() method – It returns True if all the characters are numeric (0-9), otherwise False. It also considered exponent values as numeric value.
Syntax - string.isnumeric() Parameter Values - No parameter values.
Example 1- Check if all the characters in the string are numeric.
x = '1234' z = 'card no., 6528' print(x.isnumeric()) print(z.isnumeric())

isprintable() method – It returns True if all the characters are printable, otherwise False. In other words string can be combination of alphabet (a-z), number (0-9), symbol ($,@,#), whitespace, punctuation and underscore (_).
Syntax - string.isprintable() Parameter Values - No parameters.
Example 1- Check if all the characters in the string are printable.
x = 'Hello, Python world!' z = "'Hello!\n, you" print(x.isprintable()) print(z.isprintable())

If you find anything incorrect in above discussed topic and have any further question, please comment down below.
Like us on