title: Python code unexpected behavior when entering my loop
body: <p>I am having a problem with my attack loop, when it runs it gets to the <code>checkAtk</code> function then restarts the direction loop.</p>
  
  <p>I don't have a clue what's wrong with this code (and need to fix it before next Saturday). I welcome any advice or hint you might have.</p>
  
  <pre><code>import random
  import time
  
  #We define the intro function to introduce the player to the world
  def displayIntro():
      # [...] content: calls to print() and sleep()
  
  #Define a function to ask the player what direction they want to go
  def chooseDir():
      direction = ''
      while direction != '1' and direction != '2' and direction != '3' and direction != '4':
          # [...] content: calls to print() and sleep()
          direction = input()
      return direction
  
  #Define a function that check if the direction = a random int that the computer generates
  def checkDir(direction, health, mana, money):
      # [...] content: calls to print() and sleep()
      friendlyDir = random.randint(1, 4)
      #If it does the player recieves 100 Rupees
      if direction == friendlyDir:
           # [...] content: calls to print() and sleep()
           health = 100
           mana = 100
           money = money + 100
      #if it dosent match we prepare for a fight
      else:
          # [...] content: calls to print() and sleep()
  
  #define a function to ask the player to choose an attack
  def chooseAtk(mana):
      chooseAtk = ''
      while chooseAtk != '1' and chooseAtk != '2' :
          # [...] content: calls to print() and sleep()
          #if players mana is &gt; 0 they get a choice of a strength or a mana attack
          if mana &gt; 0:
              # [...] content: calls to print() and sleep()
              chooseAtk = int(input())
          #if players mana &lt; 0 the attack automatically goes to strength
          else:
              chooseAtk = 1
      return chooseAtk
  
  #define a function to check the attack against Player Attack Power vs Monster Defense
  def checkAtk(chooseAtk, health, mana, money):
      while chooseAtk == 1 and health &gt; 0:
          if playerAp &gt; monsterDef:
              # [...] content: calls to prin() and sleep()
              money = money + 100
          else:
              # [...] content: calls to print() and sleep()
              health = health - 10
      #if player chooses a mana based attack its Player Magic Power vs Monster Defense
      while chooseAtk == 2 and health &gt; 0 and mana &gt; 0:
          if playerMp &gt; monsterDef:
              # [...] content: calls to print() and sleep()
              money = money + 100
              mana = mana - 10
          else:
              # [...] content: calls to print() and sleep()
              health = health - 10
              mana = mana - 10
  
  #Set global variables
  health = 100
  mana = 100
  money = 0
  playerAp = random.randint(1,50)
  playerMp = random.randint(1,50)
  monsterDef = random.randint(1,50)
  
  #Initiate the loop
  displayIntro()
  
  playAgain = 'yes'
  while playAgain == 'yes' or playAgain == 'y':
      if health &gt; 0:
  
          print('------------------------------')
          print('Health: '  + str(health))
          print('Mana: ' + str(mana))
          print('Rupees: ' + str(money))
          print('------------------------------')
  
          chosenDir = chooseDir()
          checkDir(chosenDir, health, mana, money)
          chooseAtk(mana)
          checkAtk(chooseAtk, health, mana, money)
  
  while health == 0:
          print('Do you want to play again? (yes or no)')
          playAgain = input()   
  </code></pre>