three_words = ["Ant", "Run", "Worm"]
print(three_words)
three_words[0].upper()
three_words[2].swapcase()
print(three_words)使用这样的代码,它会打印以下内容
#['Ant', 'Run', 'Worm']
['Ant', 'Run', 'Worm']我知道大写和大写的函数没有被读取,但我不知道为什么
发布于 2022-07-28 21:15:16
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)发布于 2022-07-28 21:17:28
没有分配结果。因此,您可以对变量调用一个函数,但是如果您不将函数的结果赋值给一个变量,那么这个函数就完成了这个工作,但是它没有被保存。
因此,例如,您可能希望分配three_words[0]= three_words[0].upper()和three_words[2] = three_words[2].swapcase()
https://stackoverflow.com/questions/73159208
复制相似问题