Ваш счет >>> 10
Хотите снова пройти тест? Y или N: n
5: горячий
5: 2qa3ws8ujhyi9; [] \ ']
2: zzzz
2: у
10: ТЕСТ
До свидания!
template = """{score} : {name}"""
display_good = template.format(score=score,name=user_name)
highscore_a = open("highscoreFile.txt",'a') #The file that keeps the highest scores of all time
highscore_a.write(display_good)
highscore_a.write('\n')
highscore_a.close()
highscore_r = open("highscoreFile.txt", "r")
read_top_5 = highscore_r.readlines()
read_top_5.sort(reverse=True)
i =[5]
repeat = (read_top_5[-5:])
for i in repeat:
print(i)