how do you solve the error ‘list assignment index out of range’ in python?

Use this:

weeknumber = []
for i in range(28):
    weeknumber.append([])
    for j in range(35)):
        weeknumber[i].append(pd.Timestamp(date_range[i][j]).weekofyear)

For an explanation of why you get surprising results to your other approach, refer to this answer to your other question

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top