'How do you make sure a txt file with a dictionary in it can't be edited?

So I am trying to add save files to my text-adventure game that can't be edited by the user. This is so that they can't cheat by editing the dictionary inside of it. So far all I've done is a few algorithms that can be easily bypassed if you connected the dots. Basically it's this.

import sys,os,ast
dictionary = {...}
save_dictionary = {...}
def save():
    filehandler = open("dictionary.txt", "a")
    data = str(dictionary)
    filehandler.write(data)
    filehandler.close()

def savecode():
    savecode = dictionary.values()
    total = sum(savecode)
    save_dictionary['savecodes'] = round(math formulas)
    filehandler = open("save_dictionary.txt", "a")
    data = str(save_dictionary)
    filehandler.write(data)
    filehandler.close()

def load():
    with open('dictionary.txt') as f:
        data = f.read()
        save = ast.literal_eval(data)
        f.close()

But the problem I'm facing is that it is easily by-passible if you just add an amount and equally subtract an amount, which would make the sum the same, making everything work the same. I did make it so that anytime the game itself detects any changes it immediately deletes all save files and makes you start over.

So is the solution making the files unable to be accessed at all? Or is it that the python file will detect the time it was created? I have no idea. It could be another option.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source