title: Changing a local variable in multiple functions in Python?
body: <p>background: I'm currently writing a text-based adventure and each enemy has a certain amount of turns you can attack it before it attacks back. 
  So to handle this the code sets an argument in the function for the fight dictating how many times you can attack.</p>
  
  <pre><code>def fight_sequence(rounds):
    while rounds &gt; 0:
      attack = input()
      if attack == magic:
        magic("you teleport away to safety. Congratulations you have stayed alive through your journey and found a few souvenoirs. nice job!", 1, "you muster up all of your energy, chant the spell.... and nothing happens.Cthulu... seems unimpressed", 1, "")
      elif attack == sword:
        sword(1)
  def magic(teleportmessage, teleportsuccess, firemessage, firefail, winmessage):
    x = 0
    while x == 0:
      fightorflight = input("""you open the book to cast a spell
      Do you want to try teleporting or use a fireball?""").lower()
      if "teleport" in fightorflight:
        if teleportsuccess = 1:
          print(teleportmessage)
          x = 1
        else:
          choice = input("You can't teleport out of this battle. Would you like to try a fireball?")
          if choice == yes:
            fightorflight = "fireball"
          else:
            x = 1
      elif "fire" in fightorflight:
        print(firemessage)
        if firefail == 1:
          choice = input("do you want to try to teleport instead?").lower()
          if "yes" in choice:
            fightorflight = "teleport"
          else:
            x = 1
        else:
          print(winmessage)
      else:
        print("Sorry not sure what you mean")
  def sword(attacksuccess):
    if attacksuccess == 1:
      print("You pull out the sword and swing at the monster damaging it severely.")
    else:
      print("You pull out the sword and swing at the monster, but its immune to blunt objects.")
  fight_sequence(3)
  </code></pre>
  
  <p>both magic() and sword() need to be able to decrease rounds by 1, originally i just did that before entering the magic or sword function. however some items to attack with allow you to attack more than once if you want so that won't work for them. Such as magic if they also choose to teleport. Is there a way to allow me to change the variable rounds while inside of another function?
  I think using a return value might help but I'm not sure how to go about it</p>