How to use pickle to save data to disk?

pickle, python

Solution

Save an object containing the game state before the program exits:

`pickle.dump(game_state, open('gamestate.pickle', 'wb'))`

Load the object when the program is started:

`game_state = pickle.load(open('gamestate.pickle', 'rb'))`

In your case, game_state may be a list of questions.

Problem

I'm making a Animal guessing game and i finish the program but i want to add pickle so it save questions to disk, so they won't go away when the program exits. Anyone can help?

Original source