+ 3

Grid loop

can anyone help with the task? Character Picture Grid 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.... Hint: You will need to use a loop in a loop in order to print grid[0][0], then grid[1][0], then grid[2][0], and so on, up to grid[8][0]. This will finish the first row

20th Jul 2018, 1:31 PM
tardigrade
tardigrade - avatar
4 Respuestas
+ 1
help you in printing the list in the way you mentioned?
20th Jul 2018, 1:43 PM
Satyam
+ 1
yes, if you can then all solution )
20th Jul 2018, 1:52 PM
tardigrade
tardigrade - avatar
+ 1
for i in grid: print(''.join(i))
20th Jul 2018, 1:54 PM
Satyam
+ 1
what other solution do you need?
20th Jul 2018, 1:54 PM
Satyam