How to shift list indexes by a certain value in Python
<p>I need to create a python function that right shifts values in a list by a given value. </p>

<p>For example if the list is [1,2,3,4] and the shift is 2 it will become [2,3,4,1]. the shift value must be a non negative integer. I can only use the len and range functions. </p>

<p>This is what I have so far</p>

<pre><code>def shift(array, value):
    if value &lt; 0:
        return
    for i in range(len(array)): 
        arr[i] = arr[(i + shift_amount) % len(arr)]
</code></pre>

<p>Usually you can do this with slicing</p>

<pre><code>arr = arr[shift:] + arr[:shift] 
</code></pre>

<p>Your shifted list is only <code>shift = 1</code>, not 2. You can't get your output by shifting 2 positions.</p>

python indexing