Predict

Mirror, Mirror

A picture can be stored as a grid: a list of rows. Each row is a string or a list of colours. (canvas.rows() gives you one.)

A slice with step -1, written [::-1], makes a reversed copy:

  • row[::-1] reverses one row: a left-right mirror.
  • grid[::-1] reverses the order of the rows: a top-bottom mirror.
print("#..."[::-1])   # ...#

What happens if you do both at once?

ramp = [
    "#...",
    "##..",
    "###.",
]
new = [row[::-1] for row in ramp[::-1]]
for row in new:
    print(row)

What does this program print?