1

I've been trying to create a simple game that writes the scores in a text file so later can be read. I use this kind of code to write the scores and a similar one to read the scores:

with open('scores.txt', 'a') as record:
    record.write(myData + '\n')

This code writes scores line by line. (the way I preferred)

I was wondering if there is a better way of saving the scores on scores.txt?

kalixsal
  • 11
  • 4
  • If you have many scores in a container, like a list or dictionary, you can save and later read back the whole object in one call to `pickle.dump()` and `pickle.load()`. – martineau Jan 18 '17 at 03:07

0 Answers0