0

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.

  • This unicode character has length of 2 by design. Either change symbol for representing a mine or assume that every symbol has a length of 2, e.g. ' 2' instead of '2'. – Pawel Kam Feb 24 '23 at 14:21
  • Some of the answers to [this Q&A](https://stackoverflow.com/q/63410948/5320906) and the links that they contain my be of interest. – snakecharmerb Feb 24 '23 at 20:12

0 Answers0