Question: I write button.xml and qweb in **manifest**.py but it not worked.

button.xml (static/src/xml/button.xml)

```
<?xml version="1.0" encoding="UTF-8"?>
<templates>
    <t t-extend="ListView.buttons">
        <t t-jquery="button.o_list_button_add" t-operation="after">
            <button name="xxx" type="button" t-if='widget.modelName == "billing.info.functions"'
                    class="btn btn-sm btn-default o_import_button o_import_import">Upload
            </button>
        </t>
    </t>
</templates>

```

**manifest**.py

```
'qweb': [
        "static/src/xml/button.xml"
    ],

```

Answer: 
The first thing I notice is that you are iterating through `i in range(0, int(pages))`, however, the pages only start on line 1 (line 0 consists of n & q).

So your for loop should like more like (you also want to do +1 because you want to count the last page, otherwise python only goes 'uptil but not including'):

```py
for i in range (1, pages + 1):
    words = int(file.readline().strip())

```

Here, we are putting the .strip() function so that we don't get an error while converting this to an int. By default, text files have `\n` (enter characters) at the end of each line and python doesn't understand the meaning of `int("5\n")`. The strip() function helps get rid of the enter character and any trailing 'whitespaces'.

Now, you would want to store the number of words per line somewhere, and for this you can either use a dictionary (<https://www.w3schools.com/python/python_dictionaries.asp>), or a list.

List indices start at 0, but the line with the number of words per page starts at 1 and even though you could get away with using lists, dictionaries would be more intuitive.

```py
words_per_page = {}

```

You can look at the link I have provided to understand how these work. We can then add the words to the dictionary:

```py
for i in range (1, int(pages) + 1):
    number_of_words = int(file.readline().strip())
    words_per_page[i] = number_of_words

```

Then, you can iterate through each line with the questions. Here, we start the for loop at the line just after the line where the number of words per page ends:

```py
all_questions = []
for question_index in range(pages + 2, 1 + pages + questions):
    all_questions.append(file.readline().strip())

```

From this, you will get 1 dictionary of the page number as the key and words per page as the value and a list with all the questions. Then you could iterate through these and get the number of words in the pages:

```py
for page_number in all_questions:
    no_of_words = words_per_page[int(page_number)]
    # You can then store this variable somewhere or write to a text file

```

Now, I haven't tested any of this code, but the idea behind everything is the same. If you do get any errors, make sure to leave a comment.
Could you try this?

```py
with open("encyin.txt") as f:
    parts = next(f).split()
    pages = int(parts[0])
    questions = int(parts[1])
    counts = []
    # capture counts
    for _ in range(pages):
        num_pages = int(next(f))
        counts.append(num_pages)
    # answer questions
    for _ in range(questions):
        book = int(next(f))
        print(counts[book - 1])

```