title: Assigning python deque to list
body: <p>The problem is to rotate a list by moving the numbers from the right, k times. e.g. [1,2,3,4,5,6,7] with k=3 will rotate the numbers from the right one at a time and move them to the top of the list so the output would be [5,6,7,1,2,3,4]. Rather than using the pop and insert operation in the list, I decided to use the dequue data type in python that supports adding to the left of the list in O(1). However, I am not quite sure how the conversion happens from dequeue to list. The second function works whereas the first doesn't. If you can explain why, it would be much appreciated.</p>
  
  <pre><code>from collections import deque
  
  def rotateNums(nums, k):
    dq = deque(nums)
    for _ in range(0,k):
      num = dq.pop()
      dq.appendleft(num)
    nums = list(dq)
  
  def rotateNums(nums, k):
    dq = deque(nums)
    for _ in range(0,k):
      num = dq.pop()
      dq.appendleft(num)
    nums[:] = list(dq)
  
  nums = [1,2,3,4,5,6,7]
  k = 3
  print(f'nums before rotation: {nums}')
  rotateNums(nums, k)
  print(f'nums after rotation: {nums}')
  </code></pre>
  
  <p>Output from the first function is: nums after rotation: [1, 2, 3, 4, 5, 6, 7]</p>
  
  <p>Output from the second function is: [5, 6, 7, 1, 2, 3, 4]</p>