I am a beginner in Python. I am trying to solve the following problem using modulo function but I'm facing
error: list index out of range.
Problem: Given an array of integers arr[] of size N and an integer, the task is to rotate the array elements to the left by d positions.
Code:
def rotate(arr, d):
temp= []
n = len(arr)
for i in range(n):
temp[i]=temp[(i+d)%n]
return temp