# Resolved: I think that the for loop with index j is wrong

Giles has called n the number of coins +1, so n=1001, but the for loop with index j arrives to n, so it starts from 0 and arrives to 1000 (extremes included), but the position number 1000 doesn't exist, so it should be "range(0,n-1,i)".

And another question: why the dictionary d arrives just to 31^2 = 961 and not to 1000^2? Thank you

Hey Alessandro,

Thank you for your question!

Notice that the `coins`

list is defined as

```
coins = [0]*n
```

This means that it contains 1001 zeros. Therefore, the indices of this list go from 0 to 1000. The `range()`

function in the second `for`

-loop goes from 0 (included) to 1001 (excluded), covering all indices.

Regarding your second question, try printing out the list after the coins have been flipped, namely:

You will notice that all coins with an index larger than 961 point tails. Additionally, notice that 1000 is not an exact square: 31^2 = 961 and 32^2 = 1024, which is already larger than 1000.

Hope this helps!

Kind regards,

365 Hristina

About the second question I was confused, it's obviously clear. For the first one, it got me confused that the initial problem said we have 1000 coins, all start with heads and the step starts from 2, but here we have 1001 coins, all start from tails and the step starts from 1. But the principle is clear, thank you.