I am confused on how my code is not turning all strings into lowercase?
def set_lowercase(strings):
""" lower the case 2. """
return [i.lower() for i in strings]
strings = ['Right', 'SAID', 'Fred']
set_lowercase(strings)
print(strings)
I am confused on how my code is not turning all strings into lowercase?
def set_lowercase(strings):
""" lower the case 2. """
return [i.lower() for i in strings]
strings = ['Right', 'SAID', 'Fred']
set_lowercase(strings)
print(strings)
You need to assign the result of your function call to the variable strings
:
strings = set_lowercase(strings)
set_lowercase(strings)
doesn't modify the input in-place.
It returns a list of strings.
So, write strings = set_lowercase(strings)
instead.
Your function builds a new list and returns it, but the calling code doesn't do anything with the returned value.