Python program to convert uppercase to lowercase | The writing systems that distinguish between the upper and lowercase have two parallel sets of letters, with each letter in one set usually having an equivalent in the other set. Lowercase letters are the shorter, smaller versions of letters (like w), as opposed to the bigger, taller versions (like W), which are called uppercase letters.
Uppercase letters are also known as capital letters. Uppercase letters signal to the reader that something is important or significant. English alphabet uppercase letters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z.
In writing, most letters are lowercase. Lowercase letters are all letters that do not begin a sentence or refer to a proper noun. English alphabet lowercase letters: a b c d e f g h i j k l m n o p q r s t u v w x y z.
String to Lowercase Python
This python program using the built-in function to convert uppercase to lowercase. We will take a string while declaring the variables. Then, the lower() function converts all uppercase characters in a string into lowercase characters and returns it. Finally, print the lowercase string.
The syntax of lower() method is:
The lower() method doesn’t take any parameters.
Return value from string lower():
The lower() function return the lowercase string of the given string. If no uppercase characters exit, it returns the original string.
# Python program to convert uppercase to lowercase #take input string = input('Enter any string: ') # lower() function to convert uppercase to lowercase print('In Upper Case:', string.lower())
Output for the different input values:-
Enter any string: KNOW PROGRAM
In Upper Case: know program
Enter any string: CONVERT Lowercase to UPPERCASE
In Upper Case: convert lowercase to uppercase
Enter any string: PYTHON3
In Upper Case: python3
Convert Uppercase to Lowercase in Python without using Function
In this program, we used For Loop to iterate characters. we are using the If Else Statement inside the for loop to check the character is between A and Z or not. If the condition true, we are subtracting 32 from its ASCII value. Otherwise, we are coping that character to string 1. The ord() method is used to find the Unicode value of a character passed as its argument. The chr() method is used to find the character corresponding to the Unicode value passed as its argument.
# Python program to convert uppercase to lowercase # take input string = input('Enter any string: ') # convert uppercase to lowercase new_string ='' for i in range(len(string)): if(string[i] >= 'A' and string[i] <= 'Z'): new_string = new_string + chr((ord(string[i]) + 32)) else: new_string = new_string + string[i] # print lowercase string print('In Lower Case:',new_string)
Enter any string: python PROGRAM
In Lower Case: python program
Lowercase Python using ASCII values
This python program also performs the same task but in a different way. We are comparing the ASCII values to check whether there are any uppercase characters in this string. If true, we are converting them to lowercase.
# Python program to convert uppercase to lowercase # take input string = input('Enter any string: ') # convert uppercase to lowercase new_string ='' for i in string: if(ord(i) >= 65 and ord(i) <= 90): new_string = new_string + chr((ord(i) + 32)) else: new_string = new_string + i # print lowercase string print('In Lower Case:',new_string)
Enter any string: LOWERcase String
In Lower Case: lowercase string
Also See:- Python program to check vowel or consonant
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or you find anything incorrect? Let us know in the comments. Thank you!