Skip to content Skip to sidebar Skip to footer

Python: How To Make List With All Lowercase?

I am new to this whole python and the data mining. Let's say I have a list of string called data data[0] = ['I want to make everything lowercase'] data[1] = ['How Do I Do It'] data

Solution 1:

if your list data like this:

data = ['I want to make everything lowercase', '', '']
data = [k.lower() for k in data]

if your list data is a list of string list:

data = [['I want to make everything lowercase'], ['']]
data = [[k.lower()] for l in data for k in l]

the fact is that list don't has attribute 'items'


Solution 2:

You need a list comprehension, not a dict comprehension:

lowercase_data = [v.lower() for v in data]

Post a Comment for "Python: How To Make List With All Lowercase?"