Rotate a matrix

zip()in conjunction with the*operator can be used to unzip a list:

clockwise:

rotated = zip(*original[::-1])  # On Python 3, list(zip(*original[::-1]))

counter-clockwise:

rotated_ccw = zip(*original)[::-1]  # On Python 3, list(zip(*original))[::-1]

results matching ""

    No results matching ""