Simply use the Python string lower() method to convert every element in a list of strings into lowercase. It will convert given into lowercase letters in Python.
str.lower()
Example make the elements in a list of strings lowercase in Python
Simple python code:
Let’s try, given list ["a", "B", "C"]
convert into ["a", "b", "c"]
.
- Iterate through string_list
- Convert each string to lowercase
strList = ["a", "B", "C"]
for i in range(len(strList)):
strList[i] = strList[i].lower()
print(strList)
Output:
Another example
Use list comprehension to convert list strings into lowercase words.
strList = ["AA", "BB", "CC"]
strList = [x.lower() for x in strList]
print(strList)
Output:
[‘aa’, ‘bb’, ‘cc’]
Do comment if you have any doubts and suggestions on this Python list code.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.