title: Alternatives to storing variables globally
body: <p>I am starting out with Python now, working on the Learn Python The Hard Way, on exercise 36. I want to create a good game, and learn some more techniques before moving on with the next exercise. I haven't approached the subject of Classes and Object yet, yet I want to see if I can do something that would be a bit more complex than a standard first 'choose-your-own-adventure' game.</p>
  
  <p>I want to collect four different keys in 'Ganon's Lair', and then use those four keys to open a door in the 'main-hall'. I already have quite some of it worked out (not elegantly), but I still need to figure out how to store keys without them getting erased. An unelegant way is to assign them as global variables, such as I do here.</p>
  
  <pre><code>def grass_room():
  global key1
  grass_instructions = """As you enter the lair of the grass room, you see
                          a spider hanging on the ceiling, with his
                          big eye focused on you. You could grab your 1.slingshot,
                          or perhaps 2.make a run for the green-coloured key under his
                          tail?"""
      print grass_instructions
      gohma_boss = raw_input("&gt; ")
      if gohma_boss == "1":
          print "You shoot him in the eye, he falls down and dies. You grab the key, and return."
          key1 = True
      main_hall("not_empty")
      else:
          print die("You die.")
      main_hall("not_empty")
  </code></pre>
  
  <p>Any suggestions for different ways to 'save' this key across functions, besides making them global?</p>