Replacing Connect Four code with a for loop I have a Connect Four game with a board that I made with a bunch of print functions, which is incredibly inefficient:
    print(&quot;   0   1   2   3   4   5   6&quot;)
    print(&quot;   &quot; + board[0][0] + &quot; | &quot; + board[0][1] + &quot; | &quot; + board[0][2] + &quot; | &quot; + board[0][3] + &quot; | &quot; + board[0][
        4] + &quot; | &quot; + board[0][5] + &quot; | &quot; + board[0][6])
    print(&quot;  ---+---+---+---+---+---+---&quot;)
    print(&quot;   &quot; + board[1][0] + &quot; | &quot; + board[1][1] + &quot; | &quot; + board[1][2] + &quot; | &quot; + board[1][3] + &quot; | &quot; + board[1][
        4] + &quot; | &quot; + board[1][5] + &quot; | &quot; + board[1][6])
    print(&quot;  ---+---+---+---+---+---+---&quot;)
    print(&quot;   &quot; + board[2][0] + &quot; | &quot; + board[2][1] + &quot; | &quot; + board[2][2] + &quot; | &quot; + board[2][3] + &quot; | &quot; + board[2][
        4] + &quot; | &quot; + board[2][5] + &quot; | &quot; + board[2][6])
    print(&quot;  ---+---+---+---+---+---+---&quot;)
    print(&quot;   &quot; + board[3][0] + &quot; | &quot; + board[3][1] + &quot; | &quot; + board[3][2] + &quot; | &quot; + board[3][3] + &quot; | &quot; + board[3][
        4] + &quot; | &quot; + board[3][5] + &quot; | &quot; + board[3][6])
    print(&quot;  ---+---+---+---+---+---+---&quot;)
    print(&quot;   &quot; + board[4][0] + &quot; | &quot; + board[4][1] + &quot; | &quot; + board[4][2] + &quot; | &quot; + board[4][3] + &quot; | &quot; + board[4][
        4] + &quot; | &quot; + board[4][5] + &quot; | &quot; + board[4][6])
    print(&quot;  ---+---+---+---+---+---+---&quot;)
    print(&quot;   &quot; + board[5][0] + &quot; | &quot; + board[5][1] + &quot; | &quot; + board[5][2] + &quot; | &quot; + board[5][3] + &quot; | &quot; + board[5][
        4] + &quot; | &quot; + board[5][5] + &quot; | &quot; + board[5][6])
    print(&quot;  ---+---+---+---+---+---+---&quot;)
    print(&quot;   &quot; + board[6][0] + &quot; | &quot; + board[6][1] + &quot; | &quot; + board[6][2] + &quot; | &quot; + board[6][3] + &quot; | &quot; + board[6][
        4] + &quot; | &quot; + board[6][5] + &quot; | &quot; + board[6][6])
    print()

I want to know how I can replace my board using for loops such that the code will look neater and easier to change. Here is the rest of my code if you need any references.
I think like this:
print(&quot;   0   1   2   3   4   5   6&quot;)
for row in board:
    print(&quot; &quot; + &quot; | &quot;.join(row))
    print(&quot;  ---+---+---+---+---+---+---&quot;)
print()

You could put the whole thing into a single call to print by using &quot;\n&quot;.join and more string concatenation, but that would most likely make it a lot less readable.