Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def rotate_image(img):
- rotated_image = [[] for x in range(len(img))]
- for i in range(len(img)):
- for j in range(len(img[i])):
- rotated_image[len(img) - j - 1].append(img[i][j])
- return rotated_image
- image = [
- [1, 1, 5, 9, 9],
- [2, 2, 6, 0, 0],
- [3, 3, 7, 1, 1],
- [4, 4, 8, 2, 2],
- [5, 5, 9, 3, 3]
- ]
- rotated_img = rotate_image(image)
- for i in rotated_img:
- print(i)
- [9, 0, 1, 2, 3]
- [9, 0, 1, 2, 3]
- [5, 6, 7, 8, 9]
- [1, 2, 3, 4, 5]
- [1, 2, 3, 4, 5]
Add Comment
Please, Sign In to add comment