title: "while" loop exiting prematurely (python 3)
body: <p>The while loop only runs once and exits as though the condition has been met, however, when debugging for whether the condition has been met externally (after the loop) it has not.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>iFile = open("snakein.txt")
  line = iFile.readline()
  finXStr,finYStr = line.split()
  
  finX = int(finXStr)
  finY = int(finYStr)
  
  
  
  moves = []
  
  snkX = 0
  snkY = 0
  
  while snkX != finX and snkY != finY:
      if finX &gt; 0 and finX != snkX:
          moves.append("R")
          snkX += 1
          print("x moves")
      elif finX &lt; 0 and finX != snkX:
          moves.append("L")
          snkX -= 1
          print("x moves")
      elif finX == snkX:
          moves.append("L")
          snkX -= 1
          print("x moves")
      if finY &lt; 0 and moves[-1] == "R":
          moves.append("R")
          snkY -= 1
          print("y moves")
      elif finY &lt; 0 and moves[-1] == "L":
          moves.append("L")
          snkY -= 1
          print("y moves")
      elif finY &gt; 0 and moves[-1] == "R":
          moves.append("L")
          snkY += 1
          print("y moves")
      elif finY &gt; 0 and moves[-1] == "L":
          moves.append("R")
          snkY += 1
          print("y moves")
      elif finY == snkY:
          moves.appebd("L")
          snakeY -= 1
          print("y moves")
  
  output = moves
  
  oFile = open("snakeout.txt", "w")
  oFile.write(str(output))
  </code></pre>
  
  <p>The program is trying to make a "snake" move in the most efficient way to a specific target via certain moves, on a "cartesian plane" like setting.</p>