Skip to content

Instantly share code, notes, and snippets.

@tejuafonja
Created September 24, 2017 08:13
Show Gist options
  • Save tejuafonja/cc47f3a1d4dc0937ae61cb694b275e0e to your computer and use it in GitHub Desktop.
Save tejuafonja/cc47f3a1d4dc0937ae61cb694b275e0e to your computer and use it in GitHub Desktop.
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', '.', '.', '.'],
['.', '.', '.', '.', '.', '.']]
"""
result =
..OO.OO..
.OOOOOOO.
.OOOOOOO.
..OOOOO..
...OOO...
....O....
"""
def charPictureGrid(grid):
for j in range(len(grid[0])):
for i in range(len(grid)):
print (grid[i][j], end="")
print()
# using zip()
# map("".join, zip(*grid)) means apply "".join to each element of zip(*grid)
print ("\n".join(map("".join, zip(*grid))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment