Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lowercase a list of lists

I have a list of lists:

data = [['SiteUrl','Url','Title'],['SiteUrl','Url','Title']]

How can I iterate through the list and lowercase all the content using python?

like image 492
dimitrisd Avatar asked Oct 19 '25 07:10

dimitrisd


1 Answers

Using a list comprehension:

data = [[x.casefold() for x in sublst] for sublst in data]

Or functionally:

data = [list(map(str.casefold, x)) for x in data]

From the docs:

Casefolding is similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string.

like image 54
jpp Avatar answered Oct 21 '25 09:10

jpp