题解 | #牛牛的朋友#

牛牛的朋友

http://www.nowcoder.com/practice/11bcc9a775b14d9f9b855634b9434b70

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)
全部评论

相关推荐

Rena1ssanc...:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
牛客刘北:如果暑期实习是27届的话,你要晚一年才会毕业,企业为什么会等你呢?要搞清时间逻辑呀!27届现在实习只能是在暑假实习,这是日常实习,不是暑期实习。所以多去投日常实习吧,暑期实习肯定不会要你的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务