user_data = {}
# Load user data from the JSON file
with open("user_data.json", "r") as f:
user_data = json.load(f)
# Save user data to the JSON file
def save_user_data():
with open("user_data.json", "w") as f:
json.dump(user_data, f)
# Define a custom method to get user data
def get_user_data(user_id):
return user_data.get(str(user_id), {})
# Define a custom method to set user data
def set_user_data(user_id, data):
user_data[str(user_id)] = {**get_user_data(user_id), **data}
save_user_data()
# Define a custom method to update user data
def update_user_data(user_id, data):
set_user_data(user_id, data)
Whenever the program is re-run I want the users to have the exact data like theri stand, coins, wins, losses they had before.