Character Picture Grid exercise - automatetheboringstuff Regarding the Character picture exercise located at the end the following page:
https://automatetheboringstuff.com/chapter4/


  Say you have a list of lists where each value in the inner lists is a
  one-character string, like this:

grid = [['.', '.', '.', '.', '.', '.'],
        ['.', 'O', 'O', '.', '.', '.'],
        ['O', 'O', 'O', 'O', '.', '.'],
        ['O', 'O', 'O', 'O', 'O', '.'],
        ['.', 'O', 'O', 'O', 'O', 'O'],
        ['O', 'O', 'O', 'O', 'O', '.'],
        ['O', 'O', 'O', 'O', '.', '.'],
        ['.', 'O', 'O', '.', '.', '.'],
        ['.', '.', '.', '.', '.', '.']]

  
  You can think of grid[x][y] as being the character at the x- and
  y-coordinates of a “picture” drawn with text characters. The (0, 0)
  origin will be in the upper-left corner, the x-coordinates increase
  going right, and the y-coordinates increase going down.
  
  Copy the previous grid value, and write code that uses it to print the
  image.

..OO.OO..
.OOOOOOO.
.OOOOOOO.
..OOOOO..
...OOO...
....O....



I wrote the following code, any feedback is appreciated.

grid = [['.', '.', '.', '.', '.', '.'],
        ['.', 'O', 'O', '.', '.', '.'],
        ['O', 'O', 'O', 'O', '.', '.'],
        ['O', 'O', 'O', 'O', 'O', '.'],
        ['.', 'O', 'O', 'O', 'O', 'O'],
        ['O', 'O', 'O', 'O', 'O', '.'],
        ['O', 'O', 'O', 'O', '.', '.'],
        ['.', 'O', 'O', '.', '.', '.'],
        ['.', '.', '.', '.', '.', '.']]

for i in range(6):
    for a in range(9):
        if a &lt; 8:
            print(grid[a][i], end="")
        else:
            print(grid[a][i])
Your code is pretty good. It's what I'd expect the author of the book to have wanted their readers to write.

Good job!



In terms of making the code more understandable/maintainable you can get the same functionality using zip, *args, ''.join and a single print.

for column in zip(*grid):
    print(''.join(column))