Emojis does not align correctly with format

158 views Asked by At

I am doing a small personal project to learn Python where you can play Minesweeper in the Console.

I wanted to add Emojis to make the output better, but for some reason the Bomb Emoji takes up to spaces and throws the alignment out the window.

I take the element at position [i][j] and do center alignment over 5 characters. The elements are always single-characters, like integeres or ''.

Thanks in advance.

Console Output

# For every row
for i in n:
    print(hline)
        
    row = ''
  
    # For every column add cell to the string
    for j in n: 
        row += f"{board[i][j]:^5}|"

    print(f" {i} |{row}")

I was expecting that all inputs will be 5 characters long, but the emoji pushes everything by one to the right.

0

There are 0 answers