I have a list of list and I need to rotate it ninety degrees. I managed to get the first new row but I couldn't get any of the others so I put the for loop in to a a function and I increased the count by one every iteration but I've just had big mess printed to the terminal.
grid = [['.', '.', '.', '.', '.', '.'],
['.', '0', '0', '.', '.', '.'],
['0', '0', '0', '0', '.', '.'],
['0', '0', '0', '0', '0', '.'],
['.', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '.'],
['0', '0', '0', '0', '.', '.'],
['.', '0', '0', '.', '.', '.'],
['.', '.', '.', '.', '.', '.']]
How I need to rotate.
'''
..00.00..
.0000000.
.0000000.
..00000..
...000...
....0....
'''
My code
def get_row(grid, new_grid, new_row, count):
for row in grid:
new_row.append(row[count])
new_grid.append(new_row)
new_grid = []
new_row = []
count = 0
for x in range(0, 6):
count = 0
get_row(grid, new_grid, new_row, count)
count +=1
for row in new_grid:
print row