Logic Building
# Take a character as input
ch = input("Enter a character: ")
# Check character type
if ch.isupper():
print("Uppercase")
elif ch.islower():
print("Lowercase")
elif ch.isdigit():
print("Digit")
else:
print("Special character")Output
Enter a character: A Uppercase Enter a character: a Lowercase Enter a character: 5 Digit Enter a character: @ Special character
Use string methods to check character type.
Key Concepts:
isupper(): checks if uppercaseislower(): checks if lowercaseisdigit(): checks if digit- Otherwise, it's a special character