Easy Tutorial
❮ Python Sort Dictionaries By Key Or Value Ref Set Copy ❯

Python String Judgement

Python3 Examples

The following code demonstrates string judgement in Python:

Example

# Filename : test.py
# author by : www.tutorialpro.org

# Test Example One
print("Test Example One")
str = "tutorialpro.org"
print(str.isalnum()) # Checks if all characters are numeric or alphabetic
print(str.isalpha()) # Checks if all characters are alphabetic
print(str.isdigit()) # Checks if all characters are numeric
print(str.islower()) # Checks if all characters are lowercase
print(str.isupper()) # Checks if all characters are uppercase
print(str.istitle()) # Checks if all words start with an uppercase letter, like a title
print(str.isspace()) # Checks if all characters are whitespace characters, \t, \n, \r

print("------------------------")

# Test Example Two
print("Test Example Two")
str = "tutorialpro"
print(str.isalnum()) 
print(str.isalpha()) 
print(str.isdigit()) 
print(str.islower()) 
print(str.isupper()) 
print(str.istitle()) 
print(str.isspace())

Executing the above code produces the following output:

Test Example One
False
False
False
True
False
False
False
------------------------
Test Example Two
True
True
False
True
False
False

Python3 Examples

❮ Python Sort Dictionaries By Key Or Value Ref Set Copy ❯