In this python program, we will learn how to check if a given character is uppercase or not. In this program, we will use two ways to check if the character is lowercase or not. First by checking if the given character is in between A-Z and the other way to check is by using built-in python function: isupper()
.
Here is the source code of the program to check if a given character is uppercase or not.
Python Program to check if a Character is Uppercase or Not
# Python Program to check if a Character is Uppercase or Not
# Take the Input from the User
ch = input("Enter any Character: ")
if(ch >= 'A' and ch <= 'Z'):
print("The Given Character", ch, "is an Uppercase Alphabet")
else:
print("The Given Character", ch, "is not an Uppercase Alphabet")
Enter any Character: A
The Given Character A is an Uppercase Alphabet
Enter any Character: x
The Given Character x is not an Uppercase Alphabet
# Python Program to Check if a Character is Uppercase or Not - using isupper() function
# Take the Input from the User
ch = input("Enter any Character: ")
if(ch.isupper()):
print("The Given Character", ch, "is an Uppercase Alphabet")
else:
print("The Given Character", ch, "is not an Uppercase Alphabet")
Enter any Character: s
The Given Character s is not an Uppercase Alphabet
Enter any Character: D
The Given Character D is an Uppercase Alphabet
Comments