Created
September 24, 2017 08:13
-
-
Save tejuafonja/cc47f3a1d4dc0937ae61cb694b275e0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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