title: Keeping the data of a variable between runs of code
body: <p>For a school project I am making a hangman game in Python. Right now my code picks a word from a dictionary like so:</p>
  
  <pre><code>WordList = ["cat", "hat", "jump", "house", "orange", "brick", "horse", "word"]
  word = WordList[random.randint(0, len(WordList) - 1)]
  </code></pre>
  
  <p>right now the list of words has to be set within the code before running it, but I added the ability to add words to the list while running it:</p>
  
  <pre><code>if command == "add":
      while True:
          print("type a word to add to the dictionary")
          print("type /b to go back to game")
          add = raw_input("word: ")
  
          if add != "/b":
              WordList = WordList + [add]
  
              print add, "added!"
          else:
              print("returning to game")
              break
  </code></pre>
  
  <p>however, once I exit the code, the added words are obviously not saved, so I would either have to manually add all the words to the list, or add a bunch of words to the list once the code starts every time. so I am wondering if there is a simple way that I can have the variable save after the code is finished, so that WordList will keep the added words next time the code starts. the program I use to write python is Jetbrains PyCharm, if that makes a difference. Apologies for any un-optimal code, I'm new to code.</p>