title: Python - How would you make the variables in this block global?
body: <p>[Python] I need to make the first 3 variables (attack, hitpoints, money) global but i dont know how because they are random (random.randint). Could someone tell me what the code should be? Thanks!</p>
  
  <p>Edit: My error is something like "local variable 'money' referenced before assignment" later in the script.</p>
  
  <p>Heres a link to the full script: <a href="http://dl.dropbox.com/u/55052881/fightprogram.txt" rel="nofollow">http://dl.dropbox.com/u/55052881/fightprogram.txt</a></p>
  
  <p>Sorry if it's really sloppy, i just started learning python a week ago.</p>
  
  <pre><code>while roll == 1:
  
      attack = random.randint(1, 100)
      hitpoints = random.randint(1, 500)   
      money = random.randint(1, 1000)
  
      attackstr = str(attack)              
      hitpointsstr = str(hitpoints)
      moneystr = str(money)
  
      print()
      print('Your attack level is ' + attackstr + '.')
      print('You have ' + hitpointsstr + ' hitpoints.')
      print('Your have ' + moneystr + ' coins.')
  
      print()
      print('Type 1 to reroll.')
      print('Type 2 to proceed.')
      reroll = input()
      reroll = int(reroll)
      if reroll == 2:
          break
  </code></pre>