So I made a gambling game where you open crates to get hats. I have it set up to save your hats between runs, but when you try to see your hats, nothing happens. The project is here: Click here
You’re loading the hat_list
from a file if it exists, but you’re reinitializing hat_list
to [""]
right after that. This will erase any hats loaded from the file. You should initialize hat_list
only if the file does not exist.
Another thing that I noticed is that in the inventory()
function, you’re using "ab"
(append binary) mode to save hat_list
. Usually this cause duplicate entries since this will append the entire list everytime. You should use "wb"
(write binary) mode to overwrite the file with the updated hat_list
.
6 Likes