-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
  • 8,031
  • 5
  • 36
  • 49
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
  • 8,376
  • 4
  • 36
  • 77
0

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

tripleee
  • 175,061
  • 34
  • 275
  • 318