

Next, we loop through each character in the string. The indexes of the lowercase letters range from 0 - 25, while the indexes of the upper case letters ranges from 26 - 51. We can also see that the lowercase letters are written first (left side), and the uppercase letters are written second (right side). There are 26 letters in the English alphabet, but the index in a list starts from 0, so the count of the alphabet is 51 (for both upper and lowercase letters). In the list above, we see that it has lowercase letters and uppercase letters. word = str(input("Enter a word: ” ))Īlphabet = Last, create the final variable that stores an empty string, which is where the lowercase letters will be stored. Then, create another variable that stores a list of uppercase letters and lowercase letters. The idea is to loop through a list of letters and replace the uppercase letters in a string with lowercase letters.įirst, create a variable that stores an input that accepts a string with uppercase letters. In this article, we will look at two different ways. Other Ways to Convert a Python String to LowercaseĪpart from the inbuilt method “.lower()”, there are different ways of converting uppercase letters to lowercase letters in Python. lower() method, it converts those letters to lowercase.
Python string code#
We can see in the above code block that the variables that store each string have uppercase letters. The “.lower() “ method changes the strings to lowercase. It also applies to strings that have letters both in uppercase and lowercase. In Python, there is a built-in method that can change a string that is in uppercase to lowercase.

When changing a string to lowercase, it only applies to the letters. You can write the English alphabet as uppercase or lowercase letters. Strings can consist of different characters – one of those characters being letters of the alphabet.
Python string how to#
How to Convert a String to Lowercase using.

In this article, we will learn how to convert uppercase letters to lowercase letters without using the built-in method. title() method to capitalize the first letter. These methods are built-in functions that change the results of the string.įor instance, if I want to print out my name with its first letter capitalized, I use the. In Python, there are different ways of working with strings. These characters can be letters, symbols, or numbers. A string is a datatype that consists of characters wrapped in quotation marks.
