```
queen = [x - 1, y - 1]
spaces = [[],
         [],
         [],
         [],
         [],
         [],
         [],
         []]

for y in range(8):
    for x in range(8):
        # queen check
        if x == queen[0] and y == queen[1]:
            spaces[y].append("D")

         # diagonal check
        elif y < queen[1]:
            if queen[0] - x == queen[1] - y:
                spaces[y].append("*")

        elif y > queen[1]:
            if x - queen[0] == y - queen[1]:
                spaces[y].append("*")

        # straight check
        elif x == queen[0] or y == queen[1]:
            spaces[y].append("*")

        else:
            spaces[y].append(".")

```

In this code I go from the upper left corner of a board and check each one of the spaces if they either the queen, in which case I append D, or if they are diagonal from the queen or in the same column or line as the queen in which case I append \*. If none of these are filled I append a dot.

When I run the code without the diagonal check I get this correct output:

[![](https://i.stack.imgur.com/nSxmS.png)](https://i.stack.imgur.com/nSxmS.png)

But when I run it with the diagonal check I get this mess:

[![enter image description here](https://i.stack.imgur.com/gCx0E.png)](https://i.stack.imgur.com/gCx0E.png)

I don't have any idea why this is happening, could someone help please?