I have two lists asking for user input that are names and scores, so they relate to each other but aren't connected in any way.
I want to either order by name or score, but if I order either, the name and score doesn't match.
How would I be able to order one list and change the order of the other list so the score for a person is the same as their name?
This is my full code:
test_scores = []
names = []
while -1 not in test_scores:
print()
test_scores.append(int(input("Enter test score: ")))
names.append(input("Enter students name: "))
test_scores = test_scores[:-1]
print ()
print(names, test_scores )
order = input("How do you want to order the list? N for by name or S for by score: ")
if order == "S" or order == "s":
test_scores = sorted(test_scores, reverse=True)
elif order == "N" or order == "n":
names = sorted(names, reverse=False)
print(names, test_scores )
index = 0
for count in range (len(test_scores)):
print(f"{names[index]} got {test_scores[index]}")
index+=1