All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

How To Convert Lowercase To Uppercase In Python

Last Updated : Mar 11, 2024

How To Convert Lowercase To Uppercase In Python

In this article we will show you the solution of how to convert lowercase to uppercase in python, an uppercase to lowercase conversion Python application.

There are two parallel sets of characters in writing systems that discriminate between uppercase and lowercase letters, and each letter in one set typically has an identical in the other.

In contrast to their larger, taller counterparts, uppercase letters are the smaller, shorter variants of letters (like w). Now let us discuss the idea of uppercase to lowercase conversion in Python.

Step By Step Guide On How To Convert Lowercase To Uppercase In Python :-

Method - Lowercase to Uppercase String without Function

print("Enter String: ", end="")
text = input()
for i in range(len(text)):
    if text[i]>='a' and text[i]<='z':
        ch = text[i]
        ch = ord(ch)
        ch = ch-32
        ch = chr(ch)
        text = text[:i] + ch + text[i+1:]
print("\nIts Uppercase:", text)
  1. Here you can see that we write the python code for converting lowercase to uppercase in python with the help of string without function.
  2. This program is created to operate with string.
  3. That is, this program converts lowercase string entered by user to its equivalent uppercase string.
  4. In the beginning of the code we take some text in input format from the user.
  5. After that we used for loop for scanning all the characters present in the string.
  6. Then compared whether the character at current index is a lowercase character or not.
  7. If the character found as a lowercase character, then that character gets converted into uppercase.
  8. new string after converting the current index's character to uppercase, gets initialized as new value of text.
  9. We also use len, here len is the length of string.
  10. While slicing the string using indexing, that is [:], the index number before colon is included, whereas the index number after colon is excluded.
  11. And in the last we use the print function for printing the string taken from user in uppercase letters.

Method - Using ASCII values, convert lowercase to uppercase characters.

print("Enter the Character: ")
ch = input()
chup = ord(ch)
chup = chup-32
chup = chr(chup)
print("\nIts Uppercase is: ", chup)
  1. Here you can see that we write the python code for converting lowercase to uppercase in python.
  2. This program uses ASCII value of character to convert the character in uppercase.
  3. We take user input in string format at the beginning of the function.
  4. Then ord() method is then used to determine the Unicode value of such a character that is supplied as an argument.
  5. Next, we utilise the chr() method to locate the character that corresponds to the Unicode value that was supplied as its argument.
  6. It states that the value of chup gets subtracted with 32. This statement is used to initialize the ASCII value of corresponding uppercase character.
  7. Then the character corresponding to the ASCII value of 67, that is C gets initialized to chup. The character is changed to uppercase in this manner.
  8. In the last we use print function in python for printing the conversion of string from lowercase to uppercase.

Conclusion :-

Hence we have successfully learned the concept of how to convert lowercase to uppercase in python.

We also learned that the conversion of string with ASCII value and string without function.

As well as we learned that Uppercase letters are also known as capital letters.

Uppercase letters signal to the reader that something is important or significant. In writing, most letters are lowercase.

Lowercase letters are all letters that do not begin a sentence or refer to a proper noun.

I hope this article on how to convert lowercase to uppercase in python helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Amruta

Amruta is an Experienced web developer with 4 years for experience she completed her master's with MCA and passionate about programming Languages for creating technical contents like HTML, CSS, JavaScript, Java, Python, PHP, jQuery.

Follow Amruta On Linkedin 🡪