Chopper墨
2020-10-25 18:22
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L[0]='Ellena'
L[1]='Alice'
L[4]='Bob'
print(L)
# 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))
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
N = [89,72,88,79,99]
dictA=dict(zip(L,N))
dictB=sorted(dictA, key=dictA.get, reverse = True)
print(dictB)
对的 不用全部替换
Python3 入门教程(新版)
154167 学习 · 1075 问题
相似问题