NP33 牛牛的朋友

思路:

step1:首先创建并打印原列表;
step2:定义replace函数,将friends[index] = index;
step3:遍历列表,每次遍历,均调用一下replace函数;
step4:打印更新后的列表;

代码如下:

friends_list = ['Niu Ke Le', 'Niumei', 'Niuneng', 'GOLO']
print(friends_list)

def replace(friends_list,index):
    friends_list[index] = index

for i in range(len(friends_list)):
    replace(friends_list,i)
print(friends_list)