Problem z drukowaniem w pętli / Gra w kółko i krzyżyk

Problem z drukowaniem w pętli / Gra w kółko i krzyżyk
LK
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 58
0

Witam,
Mam problem ponieważ nie do końca wiem jak zmienić mój kod tak aby otrzymać upragniony rezultat. Chciałbym aby w każdej linii były wypisane liczby kolejno z game[0], game[1] i game[2] a póki co otrzymuje trzy razy wynik z game[0].

Kopiuj
game = [[1, 2, 3],
        [2, 4, 3],
        [2, 5, 1]]

def drawBoard(size):
    dashes = '---'
    pipes = '|' 
    dashesSize = 3 * size + (size + 1)
    
    for howMany in range(size):
        print('{{:>{}}}' .format(dashesSize).format((dashes + ' ') * size), end='')
        
        #print('\n')
        
        iterator = 0
        
        for line in game:
            print('\n\n' + pipes, end=' ')
            for number in line:
                print(line[number-1], end=' ')
                print(pipes, end=' ')
            break
# =============================================================================
#         for number in range(len(game)):
#             print((pipes), end=' ')
#             print(game[number], end=' ')
# =============================================================================
        #print((pipes), end=' ')    
        print('\n')
        
    print('{{:>{}}}' .format(dashesSize).format((dashes + ' ') * size), end=' ')
        

drawBoard(3)
ledi12
  • Rejestracja: dni
  • Ostatnio: dni
  • Lokalizacja: Wrocław
3
Kopiuj
game = [[1, 2, 3],
        [2, 4, 3],
        [2, 5, 1]]

def drawBoard(size):
    dashes = '---'
    pipes = '|' 
    dashesSize = 3 * size + (size + 1)

    for howMany in range(size):
        print('{{:>{}}}' .format(dashesSize).format((dashes + ' ') * size), end='')

        #print('\n')

        print("\n", (*[str(x) + " |" for x in game[howMany]]))

# =============================================================================
#         for number in range(len(game)):
#             print((pipes), end=' ')
#             print(game[number], end=' ')
# =============================================================================
        #print((pipes), end=' ')    
        print('\n')

    print('{{:>{}}}' .format(dashesSize).format((dashes + ' ') * size), end=' ')

drawBoard(3)

Zarejestruj się i dołącz do największej społeczności programistów w Polsce.

Otrzymaj wsparcie, dziel się wiedzą i rozwijaj swoje umiejętności z najlepszymi.