title: List rotation of first element in the list and moving it to the end using python
body: <p>A list rotation consists of taking the first element and moving it to the end. For instance, if we rotate the list [1,2,3,4,5], we get [2,3,4,5,1]. If we rotate it again, we get [3,4,5,1,2].</p>
  
  <p>Write a Python function rotatelist(l,k) that takes a list l and a positive integer k and returns the list l after k rotations. If k is not positive, your function should return l unchanged. Note that your function should not change l itself, and should return the rotated list.</p>
  
  <p>Here are some examples to show how your function should work.</p>
  
  <pre><code>&gt;&gt;&gt; rotatelist([1,2,3,4,5],1)
  [2, 3, 4, 5, 1]
  
  &gt;&gt;&gt; rotatelist([1,2,3,4,5],3)
  [4, 5, 1, 2, 3]
  
  &gt;&gt;&gt; rotatelist([1,2,3,4,5],12)
  [3, 4, 5, 1, 2]
  </code></pre>
  
  <p>i have tried solving it but the desired output is not coming</p>
  
  <p>This is my code but it shows different output</p>
  
  <pre><code>def rotatelist(l,k): 
      if(k&gt;0):
          o=-1
          p=1
  
          while(o&lt;=k):
              x=l.pop(p)
              l.insert((p-1),x)
              o+=1
      else:
          return(l)
      return(l) 
  </code></pre>
  
  <p>Input                         </p>
  
  <pre><code>list([1,2,3,4,5],1)
  </code></pre>
  
  <p>Expected Output          </p>
  
  <pre><code>[2, 3, 4, 5, 1]
  </code></pre>
  
  <p>Actual Output</p>
  
  <pre><code>[2, 1, 3, 4, 5]
  </code></pre>