I am trying to execute the following python code:

```def construct(s, k, a):
index = 0
# Finding the index which is not -1
for i in range(s):
if (a[i]!=-1):
index = i
break
# Calculating the values of the indexes index-1 to 0
for i in range(index-1, -1, -1):
if (a[i]==-1):
a[i]=(a[i + 1]-1 + k)% k
# Calculating the values of the indexes index + 1 to n
for i in range(index + 1, s):
if(a[i]==-1):
a[i]=(a[i-1]+1)% k
print(a)
# Driver code
s, k = 6, 7
a = [1, 2, 3, 4, 5]
construct(s, k, a)```

I get the following error:

`IndexError: list index out of range` Jun 17, 2019 in Python 3,605 views

## How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

## How to filter out any digit that contains odd number in a range of number in Python?

n = list(range(10)) b = list(filter(lambda i:i%2!=0,n)) print(b) READ MORE

## How do I obtain the index list in a NumPy Array of all the NaN values present using Python?

Hi, it is pretty simple, to be ...READ MORE

## Is there a way to list out in-built variables and functions of Python?

The in-built variables and functions are defined ...READ MORE

+1 vote

## Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

## How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE