为什么我的函数参数不能在python中正确传递?

时间:2019-12-10 19:49:50

标签: python python-3.x function for-loop

我有以下代码

magicians=['andrew','mike','bella']
def change(names):
    for name in names:
        name='the great '+name

change(magicians)
print(magicians)

预期输出:

['the great andrew', 'the great mike', 'the great bella']

实际输出:

['andrew', 'mike', 'bella']

传递的变量似乎没有变化

0 个答案:

没有答案