0
three_words = ["Ant", "Run", "Worm"]
print(three_words)

three_words[0].upper()
three_words[2].swapcase()

print(three_words)

With the code like this it prints the following

#['Ant', 'Run', 'Worm']
['Ant', 'Run', 'Worm']

I understand that the upper and swapcase function arent being read but I dont know why

wkl
  • 77,184
  • 16
  • 165
  • 176
  • 1
    You need to assign the results. For example, try `three_words[0] = three_words[0].upper()`. – j1-lee Jul 28 '22 at 21:12

2 Answers2

0
three_words = ["Ant", "Run", "Worm"]
print(three_words)

three_words[0] = three_words[0].upper()  # change the value in list
three_words[2] = three_words[2].swapcase()  # change the value in list

print(three_words)
Nesi
  • 286
  • 2
  • 15
0

The results are not assigned. So, you can call a function on variable, but if you don't assign the result of the function to a variable, then the function did the work, but it was not saved.

So for instance, you would want to assign three_words[0]= three_words[0].upper() and three_words[2] = three_words[2].swapcase()

Askar
  • 88
  • 6