How to convert a List to Lowercase in Python

Hello guys. How are you? I hope you all fine. In this tutorial we will learn about How to convert a List to Lowercase in Python. So by different methods we will convert our list to lowercase. Sometimes we need our list in lower case so these methods will convert your list into the lowercase. So without wasting your time lets learn how we can convert it to lowercase.

How to convert a List to Lowercase in Python

Advertisements
  1. Convert a List to Lowercase in Python

    to convert a List to Lowercase in Python just str.lower(). By using str.lower() you can convert all the uppercase character into the lowercase character. Here i am making my list and then using for loop with str.lower() function. This will change all my uppercase character into lowercase. We can also do the opposite of it by using str.upper() and make our list into uppercase characters. Lets learn this method by given below example: mystr = ["MangO","gRapEs","ORAngE"] for i in range(len(mystr)): mystr[i] = mystr[i].lower() print(mystr) Output : ['mango', 'grapes', 'orange']

  2. How to convert a List to Lowercase in Python

    to convert a List to Lowercase in Python just Use map(). You can use map() function to change your uppercase character into lowercase. Here we will use map() function with lambda and also use lower() function and then print it. It will give us the lowercase character's list as in output. So lets learn this by given below example: mystr = ["MangO","gRapEs","ORAngE"] var1 = (map(lambda x: x.lower(), mystr)) var2 = list(var1) print(var2) Output : ['mango', 'grapes', 'orange']

Method 1: str.lower()

Advertisements

By using str.lower() you can convert all the uppercase character into the lowercase character. Here i am making my list and then using for loop with str.lower() function. This will change all my uppercase character into lowercase. We can also do the opposite of it by using str.upper() and make our list into uppercase characters. Lets learn this method by given below example:

mystr = ["MangO","gRapEs","ORAngE"]
for i in range(len(mystr)):
    mystr[i] = mystr[i].lower()
print(mystr)

Output :

['mango', 'grapes', 'orange']

Method 2: Use map()

Advertisements

You can use map() function to change your uppercase character into lowercase. Here we will use map() function with lambda and also use lower() function and then print it. It will give us the lowercase character’s list as in output. So lets learn this by given below example:

mystr = ["MangO","gRapEs","ORAngE"]
var1 = (map(lambda x: x.lower(), mystr))
var2 = list(var1)
print(var2)

Output :

['mango', 'grapes', 'orange']

Method 3: Use list comprehension

Advertisements

We can also use the list comprehension method to convert a list to lowercase. Here first of all we will make a list which we want to convert into the lowercase which contains some uppercase character which we want to change and then we will use x.lower() function. By the help of this we can change the uppercase character into the lowercase as you can see in my output. So lets learn this method by given below example. I hope you like it.

mystr = ["MangO","gRapEs","ORAngE"]
var1 = [x.lower() for x in mystr]
print(var1)

Output :

['mango', 'grapes', 'orange']

Conclusion

Advertisements

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment