How to Convert a List of Strings to Lowercase in Python?

Find out how to make all strings lowercase in a Python list

In Python, you can make all strings in a list of strings lowercase by calling the lower() method on every element of the list, for example, using list comprehension, like so:

items = ['FOO', 'Bar', 'bAz']
newList = [item.lower() for item in items]

print(newList) # ['foo', 'bar', 'baz']

The code above would create a new list with all strings in the list in lowercase. This is equivalent to the following, which uses map():

items = ['FOO', 'Bar', 'bAz']
newList = list(map(lambda item: item.lower(), items))

print(newList) # ['foo', 'bar', 'baz']

However, using list comprehension provides a more readable and concise syntax. For that reason, it is generally preferred and would be the recommended way.

For completeness sake, you can also achieve the same result with a simple for..in loop:

items = ['FOO', 'Bar', 'bAz']
newList = []

for item in items:
    newList.append(item.lower())

print(newList) # ['foo', 'bar', 'baz']

However, it might not be the best choice as it would create/overwrite a variable named "item", which would persist even after the loop completes:

items = ['FOO', 'Bar', 'bAz']
newList = []

for item in items:
    newList.append(item.lower())

print(item) # 'bAz'

Hope you found this post useful. It was published . Please show your love and support by sharing this post.