How can I create a list that I can add to at the end of the piece of code and that I can use and add more to the next time I run through the code?
So I’m doing my NEA for GCSE Computer Science and I need to creat this game and save the top 5 scores in an external file. My plan is to put all of scores from game into a list, then sort the list so that the scores are in descending order, then display the first 5 elements of the list in the external file. I can’t create the list before I enter the score because it will be empty when I run the code again and I can’t add anything to a list that I haven’t made yet!
Top5=[]
Top5.append([name, score])
#I can’t use this because it will wipe the list every time I use the code
Top5.append([name, score])
#I can’t use this because there is no list created to add to
Basically, I want a list that I can keep adding things to every time I run through the code. How do I do this?