-3

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)
chuddles
  • 19
  • 5

3 Answers3

3

You need to assign the result of your function call to the variable strings:

strings = set_lowercase(strings)
Keiwan
  • 7,711
  • 5
  • 33
  • 48
1

set_lowercase(strings) doesn't modify the input in-place.
It returns a list of strings.

So, write strings = set_lowercase(strings) instead.

Anmol Singh Jaggi
  • 7,859
  • 3
  • 36
  • 72
0

Your function builds a new list and returns it, but the calling code doesn't do anything with the returned value.

tripleee
  • 158,107
  • 27
  • 234
  • 292