Code: Select all
def flip(image,vertical=False):
height = len(image)
width = len(image[0])
for row in range(height):
for col in range(width//2):
pixel = image[row][col]
image[row][col] = image[row][width - col - 1]
image[row][width - col - 1] = pixel
if vertical == True:
image[row][col] = image[height-row-1][width - col - 1]
image[height-row-1][width - col - 1] = pixel
return True