isupper()
The isupper() method returns True if all the characters are in upper case, otherwise False.
Numbers, symbols and spaces are not checked, only alphabet characters.
Syntax
string.isupper()
Example
Check if all the characters in the text are in upper case
n=”computer”
print(n.isupper())
Output:
False
n=”Computer”
print(n.isupper())
Output:
False
n=”COMPUTER”
print(n.isupper())
Output:
True
n=”computer123″
print(n.isupper())
Output:
False
n="computer" print(n.isupper()) n="Computer" print(n.isupper()) n="COMPUTER" print(n.isupper()) n="computer123" print(n.isupper())
Output:
False
False
True
False
isdigit()
The isdigit() method returns True if all the characters are digits, otherwise False.
Syntax
string.isdigit()
Example
Check if all the characters in the text are digits:
n=”1234″
print(n.isdigit())
Output:
True
n=”1234abc”
print(n.isdigit())
Output:
False
n=”abc1234″
print(n.isdigit())
Output:
False
n="1234" print(n.isdigit()) n="1234abc" print(n.isdigit()) n="abc1234" print(n.isdigit())
Output:
True
False
False
isalnum()
The isalnum() method returns True if all the characters are alphanumeric, meaning alphabet letter (a-z) and numbers (0-9).
Example of characters that are not alphanumeric: (space)!#%&? etc.
Syntax
string.isalnum()
Example
Check if all the characters in the text are alphanumeric
n=”hello”
print(n.isalnum())
Output:
True
n=”hello123″
print(n.isalnum())
Output:
True
n=”hello@#$”
print(n.isalnum())
Output:
False
n=”12345″
print(n.isalnum())
Output:
True
n="hello" print(n.isalnum()) n="hello123" print(n.isalnum()) n="hello@#$" print(n.isalnum()) n="12345" print(n.isalnum())
Output:
True
True
False
True
Python String inbuilt Methods Python Math inbuilt Methods Python Date And Time inbuilt Methods Python Random inbuilt Methods