My code all works and the List works but for some reason when I try to sort it , the list doesn't sort to ascending order but instead a random order.So while the list changes it doesn't to descending order. When I tried the x.sort(reverse=True) an error message popped up saying it couldn't be in integer form. Can anyone help me?
score=input('What is your score?')
Scorefile=open('score.txt','a')
Scorefile.write(score)
Scorefile.write("\n")
Scorefile.close()
Scorefile = open('score.txt','r')
with open('score.txt','r') as Scorefile:
scores=Scorefile.readline()
List=[]
while scores:
scores2=(scores.strip())
int(scores2)
List.append(scores2)
scores=Scorefile.readline()
List.sort()
print(List)
#Output(not in ascending order)
['12', '12', '12', '12', '12', '13', '15', '17', '4', '5', '6']