For example, if N=2, given the input array [1, 2, 3, 4, 5, 6]

the function should return [5, 6, 1, 2, 3, 4]

if N=3 then [4, 5, 6, 1, 2, 3]

Check this code:

def rotate(array, n): length = len(array) if n > 0: tail = array[length - n:] head = array[0:length - n] new_array = tail + head else: tail = array[- n:] head = array[0:- n] new_array = tail + head print(new_array)

def rotate(array, n):

length = len(array)

if n > 0:

tail = array[length - n:]

head = array[0:length - n]

new_array = tail + head

else:

tail = array[- n:]

head = array[0:- n]

print(new_array)