Uppercase Lowercase Conversion of an Input String in Python3

Uppercase Lowercase Conversion in Python

Uppercase Lowercase Conversion of Alphabets:

  • The user inputs a string.
  • The user wants to convert uppercase alphabets to lowercase alphabets.
  • Also, to convert lowercase alphabets to uppercase alphabets.
  • Now, the program should execute the desired output.

The below image shows an example of the Lowercase to Uppercase Alphabet Conversion. Here you can see that the starting letter is an uppercase alphabet, due to that it remains unchanged.

Uppercase Lowercase Conversion python

The following is the code snippet and the outputs.

Uppercase Lowercase Conversion in Python

PROGRAM: This code includes both functions i.e., (A -> a and b -> B)

The following Python program will convert Uppercase letters to Lowercase and Lowercase letters to Uppercase

s=input("Input a String: ")         #input string here
a=list(s)
b=[]
for c in a:                         #takes each character from string at a time
    if c.isupper():                 #checks whether the character is uppercase or not
        b.append(c.lower())         #converts the uppercase alphabets to lowercase alphabets
    elif c.islower():               #checks whether the character is lowercase or not
        b.append(c.upper())         #converts the lowercase alphabets to uppercase alphabets
    else:
        b.append(c)
print("Entered String after Modification:")
for i in range(len(b)):
    print(b[i],end="")              #print

OUTPUT 1:

Input a String: Priyam Sur
Entered String after Modification:
pRIYAM sUR

OUTPUT 2:



Input a String: AAAAbbbbCCCCddddEEEEffffGGGGhhhh
Entered String after Modification:
aaaaBBBBccccDDDDeeeeFFFFggggHHHH

Also Read:

Leave a Reply

Your email address will not be published. Required fields are marked *