问题遇到的现象和发生背景
为什么没有结果输出?
问题相关代码,请勿粘贴截图
def make_great(magicians):
great_magicians = []
while magicians:
magician = magicians.pop()
great_magician = magician + " the Great"
great_magicians.append(great_magician)
magicians = great_magicians[:]
m = ['lucifer', 'lily', 'teena']
make_great(m)
print(m)
运行结果及报错内容
[]
我的解答思路和尝试过的方法
当把magicians = great_magicians[:] 替换为:
for great_magician in great_magicians:
magicians.append(great_magician) 后
能正常输出为函数修改数据后的结果,