質問は、次のpythonプログラムを参照しています-
# High Scores
# Maintains a list of the five highest scores and the players responsible.
hiscores = [56,45,23,11]
again = "a"
def findplace(xlist, x):
# list is in descending order
for j in range(len(xlist)-1):
if x >= xlist[j]:
xlist.insert(j, x)
return xlist
while again:
print("\n", hiscores)
score = int(input("\nEnter a score (zero to exit): "))
if score >= hiscores[3]:
hiscores = findplace(hiscores, score)
elif score == 0:
again = ""
print(hiscores)
input("\nETE")
プログラムはユーザーからスコアを取得し、十分に高い場合はリストに追加します。while ループの 3 行目の index 値を 3 に設定して、エントリ レベルを最低スコアに設定したかったのですが、これではエラーが発生します。0、1、2 は完全に機能します。私は何を間違っていますか?