Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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
strings = set_lowercase(strings)
Add a comment
set_lowercase(strings) doesn't modify the input in-place. It returns a list of strings.
set_lowercase(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.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.