modifiedSentence = 一个解决的数独很好它会打印它靠近彼此我希望它是 col 或 row 上的每 3 个进行高级 space 这意味着框

modifiedSentence = a solved sudoku well it will print it close to each other i want it to be every 3 on col or row make a advanced space it means boxs

for i in range(9):
        for j in range(9):
            print(modifiedSentence[i][j], end=" ")
        print()

modifiedSentence = 
7 8 1 2 6 9 3 4 5 
3 2 4 7 1 5 6 9 8 
5 6 9 4 3 8 1 2 7
2 9 7 3 5 4 8 1 6
4 5 3 1 8 6 9 7 2
8 1 6 9 7 2 5 3 4
9 3 8 6 4 7 2 5 1
6 4 2 5 9 1 7 8 3
1 7 5 8 2 3 4 6 9

我想要它:

7 8 1  2 6 9  3 4 5 
3 2 4  7 1 5  6 9 8  
5 6 9  4 3 8  1 2 7

2 9 7  3 5 4  8 1 6
4 5 3  1 8 6  9 7 2
8 1 6  9 7 2  5 3 4

9 3 8  6 4 7  2 5 1
6 4 2  5 9 1  7 8 3
1 7 5  8 2 3  4 6 9

意味着这个数独中的每个盒子在他的列和行中都有一个空盒子

您需要在内循环的每三次迭代中添加一个 space,并且在外循环的每三次迭代中添加一个换行符:

for i in range(9):
    if i > 0 and i % 3 == 0:
        print("")
    for j in range(9):
        if j > 0 and j % 3 == 0:
            print("", end = " ")
        print(modifiedSentence[i][j], end=" ")
    print()