Python program to convert the reverse case of an input character
ADVERTISEMENTS
In this article, you will learn how to convert the reverse case of an input character in the python programming language.
Examples
'd' after conversion 'D'
'D' after conversion 'd'
You should have knowledge of the following topics in python programming to understand this program:
- Python
String
functions - Python
input()
function - Python
if-else
condition statement - Python
print()
function
Source Code
# Python program to convert the reverse case of an input character
print ("Enter an alphabet character to convert: ", end="")
random_char = str (input ())[0]
print ("The Reverse case of the '", random_char, "' is: ' ", end="")
if random_char.islower():
random_char = random_char.upper()
else:
random_char = random_char.lower()
print (random_char,"'")
Output
Enter an alphabet character to convert: D
The Reverse case of the ' D ' is: ' d '
Explanation
In this given program, we have taken input D
from the user and applied the function to convert the input's reverse case.