title: Python load variables into an array from file
body: <p>I'm making a reddit bot and I've made it store the comment ids in an array so it doesn't reply to the same comment twice, however if I close the program the array is cleared.</p>
  
  <p>I'm looking for a way to keep the array, such as storing it in an external file and reading it, thanks!</p>
  
  <p>Here's my code:</p>
  
  <pre><code>import praw
  import time
  import random
  import pickle
  
  #logging into the Reddit API
  r = praw.Reddit(user_agent="Random Number machine by /u/---")
  print("Logging in...")
  r.login(---,---, disable_warning=True)
  print("Logged in.")
  
  
  wordsToMatch = ["+randomnumber","+random number","+ randomnumber","+ random number"] #Words which the bot looks for.
  cache = [] #If a comment ID is stored here, the bot will not reply back to the same post.
  
  def run_bot():
      print("Start of new loop.")
      subreddit = r.get_subreddit(---) #Decides which sub-reddit to search for comments.
      comments = subreddit.get_comments(limit=100) #Grabbing comments...
      print(cache)
  
      for comment in comments:
          comment_text = comment.body.lower() #Stores the comment in a variable and lowers it.
          isMatch = any(string in comment_text for string in wordsToMatch) #If the bot matches a comment with the wordsToMatch array.
  
          if comment.id not in cache and isMatch: #If a comment is found and the ID isn't in the cache.
              print("Comment found: {}".format(comment.id)) #Prints the following line to console, develepors see this only.
              #comment.reply("Hey, I'm working!")
              #cache.append(comment.id)
  while True:
      run_bot()
      time.sleep(5)
  </code></pre>