是不是可以不用全部替换掉?
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L[0]='Ellena'
L[1]='Alice'
L[4]='Bob'
print(L)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L[0]='Ellena'
L[1]='Alice'
L[4]='Bob'
print(L)
2020-10-25
# Enter a code
# coding:utf-8
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
scores = [89, 72, 88, 79, 99]
templateNames = []
templateScores = [89, 72, 88, 79, 99]
scores.sort(reverse=True)
print("降序排列后的成绩:" + str(scores))
index_Score = 0
index_TemplateScore = 0
for score in scores:
index_TemplateScore = 0
for templateScore in templateScores:
if score == templateScore:
templateNames.append(names[index_TemplateScore])
index_TemplateScore += 1
print("排列后的名字:" + str(templateNames))
举报