title: Why does this python left rotation of an array not work
body: <p>I have been trying the HackerRank practice problems and I can't figure out why my left rotate algorithm won't work. I have looked online but I can't see anyone trying to do it the same way I am. Any help would be much appreciated.</p>
  <p>a = the array
  d = the number of left rotations</p>
  <p>example:
  a = 1 2 3 4 5
  d = 4</p>
  <p>out = 5 1 2 3 4</p>
  <pre class="lang-py prettyprint-override"><code>def rotLeft(a, d):
      out = a
      length = len(a)
      startingposition = 0
  
      for number in a:
          position = startingposition
          for count in range(d):
              position -= 1
              if position == -1:
                  position = length 
          startingposition += 1
          out[position] = number
  
      return(out)
  </code></pre>