Python Program to Convert lowercase to uppercase character

Python program to convert lowercase character to uppercase character

In this tutorial, we are going to learn writing a python program to convert lowercase characters (alphabet) into uppercase characters (alphabet).

Problem Statement

For any input string, any lowercase character used in input string will be replaced with uppercase character of same alphabet as lowercase character.

For example:

Case1: if user inputs ‘Quescol’

         The output should be ‘QUESCOL’

         The ‘uescol’ of string is replaced with ‘UESCOL’

Case2: if user inputs ‘pyThon’

         The output should be ‘PYTHON’

Our logic to convert lowercase character to uppercase character

  • Our program will take a string input from the user.
  • Then program will iterate through each character of the string.
  • If any lowercase letter will found, then our program will convert it into uppercase letter using upper() function.
  • And finally print the output.

Algorithm to convert lowercase character to uppercase character

Step1:  Start

Step2:   Take a string as an input from the user.

Step3: Create an empty string, as result = “ ”

Step4:  Use for loop to iterate through the string.

Step5: if lowercase found:

                  i = i.uppercase()

                 result +=i ( concatenate the characters of string)

Step6:  Stop

Python code to convert lowercase character to uppercase character of string

Output 1:

Explanation:

For the input string ‘Quescol’, all the lowercase letters i.e. ‘uescol’ is converted into respective uppercase i.e. ‘UESCOL’. While iterating through the string, the letters ‘u’, ‘e’, ‘s’, ‘c’, ‘o’, and ‘l’  return ‘True” as an output when is checked with ‘islower()’ function, then they are converted into respective uppercase letters using ‘isupper()’ function and replaced simultaneously.

Output 2:

Explanation:

For the input string ‘pytHon is fun’, all the lowercase letters i.e. ‘uescol’ are converted into respective uppercase. While iterating through the string, the letters ‘p’, ‘y’, ‘t’, ‘o’, ‘i’, ‘f’ and ‘n’  return ‘True” as an output when is checked with ‘islower()’ function, then they are converted into respective uppercase letters using ‘isupper()’ function and replaced simultaneously.