title: Rotating values in a list [Python]
body: <p>I understand this question has been asked before but I haven't seen any that answer it in a way without splitting the list.</p>
  
  <p>say I have a list:</p>
  
  <pre><code>num = [1,2,3,4,5,6]
  </code></pre>
  
  <p>I want to create a function:</p>
  
  <pre><code>rotate(lst, x):
  </code></pre>
  
  <p>So that if I call <code>rotate(num, 3)</code> it will globally edit the list <code>num</code>. That way when I later call <code>print(num)</code> it will result in <code>[4,5,6,1,2,3]</code>.</p>
  
  <p>I understand that I could write the function something like:</p>
  
  <pre><code>rotate(lst, x):
      return [lst[-x:] + lst[:-x]
  </code></pre>
  
  <p>But I need to do this function without a return statement, and without splitting the list. What I'm thinking would work would be to put the last value of the list into a variable: <code>q = lst[-1]</code> and then from there create a loop that runs <code>x</code> amount of times that continues to move the values towards the end of the list and replacing the 0th position with whatever is stored in q. </p>
  
  <p>One more thing. If I call <code>rotate(lst, -3)</code> then instead of rotating to the "right" it would have to rotate to the "left".</p>
  
  <p>I'm new to python and having trouble wrapping my mind around this concept of manipulating lists. Thank you everyone for your time and effort. I hope this problem was clear enough. </p>