标签:使用 col color gic div gre class 修改 style
第一种方法:使用enumerate函数
def make_great(magicians): for i ,name in enumerate(magicians): magicians[i] = magicians[i] + " The Great" print(magicians) magicians = [‘jack‘,‘mack‘,‘jees‘] make_great(magicians )
第二种方法:
def make_great(magicians): n = len(magicians) for num in range(0,n): magicians[num] = magicians[num] + " the Great" print(magicians[num]) magicians = [‘jack‘,‘mack‘,‘jees‘] make_great(magicians)
python对列表中名字进行修改,在每个名字后面加入‘the Great’
标签:使用 col color gic div gre class 修改 style
原文地址:https://www.cnblogs.com/wang1yi1xian1/p/11407461.html