I'm trying to write a code, which will swap two selected rectangles inside a picture. The rectangles start at a given Y-coordinate, are 100 pixels "thick" and have the width of the whole picture.

I have two separate for loops in two separate functions right now, where I can replace those pixels, but I'm not able to combine those two loops. When I write, a nested for-loop, my code keeps freezing.

Here's my code:

```
from PIL import Image

im = Image.open("Jenny-RedEyes.jpg")

def change2(y2):
    width, height = im.size
    ymin=y2
    ymax=y2+100
    xmin=0
    xmax=width

    for i in range(xmin, xmax):
        for j in range(ymin, ymax):
            r, g, b = im.getpixel((i,j))
            im.putpixel( (i,j), (50,50,50))

def change(y1):
    print(im.format, im.size, im.mode)
    width, height = im.size     
    ymin1=y1
    ymax1=y1+100
    xmin1=0
    xmax1=width    

    print (ymax1, ymin1, xmax1, xmin1)          

    for a in range(xmin1,xmax1):
        for b in range(ymin1, ymax1):
            r1, g1, b1 = im.getpixel((a,b))
            im.putpixel( (a,b), (1,1,1))  

change(0)
change2(166)
im.show()

```