Add list as list element Python weird behaviour
Solution 1:
You are not properly appending the chapters to the list Dir. I would recommend to do this, first create a dictionary where the number of the chapter is the key and then set he value of each key to be and empty list. Then use a loop to parse the dictionary and append the the page correctly to the corresponding list.
dir = {}
for chapter in range(0,25):
dir[chapter]=[]