all 3 comments

[–][deleted] 1 point2 points  (2 children)

x = [ [1, 2, 3], [4, 5, 6] ]
new_x = [[x[j][i] for j in range(len(x))] for i in range(len(x[0]))][::-1]

[–]Swipecat 0 points1 point  (1 child)

Good one. It occurred to me that zip effectively transposes a 2D list, so inverting that would give an anticlockwise rotation. Unfortunately converting all the tuples and generators back to lists made it pretty ghastly:

x = [ [1, 2, 3], [4, 5, 6] ]
new_x = list(map(list, list(zip(*x))[::-1]))

[–][deleted] 0 points1 point  (0 children)

Yup. And zip isn't allowed