想把人名和成绩绑定起来,然后排序成绩显示名字,我感觉这才是正解吧,但是我不会做,有没有带佬给给参考
# Enter a code
name=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
score=[89,72,88,79,99]
scores=[89,72,88,79,99]
scores.sort()
y=0
for a in scores:
x=0
for b in score:
if score[x]==scores[y]:
names[y]=name[x]
x+=1
y+=1
print(names)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
c = [89, 72, 88, 79, 99]
for i in range(0, len(c)-1):
for j in range(0,len(c)-1-i):
if c[j] < c[j+1]:
temp =c[j+1]
c[j+1] = c[j]
c[j] = temp
tempL =L[j+1]
L[j+1] = L[j]
L[j] = tempL
print(c)
print(L)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
c = [89, 72, 88, 79, 99]
for i in range(0, len(c)-1):
for j in range(0,len(c)-1-i):
if c[j] < c[j+1]:
tempL =L[j+1]
L[j+1] = L[j]
L[j] = tempL
print(L)