Search code examples
pythonlistlowercase

List element case conversion


I have a list that has 12 elements. I am getting an input and matching that input with the value of another variable. Now that means that case-sensitivity will be a problem. I know how to go through the list with a loop but how can I convert every character in each element to a lowercase character?

for i in sa:  
    # something here to convert element in sa to lowercase

Solution

  • A simple one liner:

    lowercase_list = [ i.lower() for i in input_list ]