In the first part, y1
is set to 0 and y2
increases from 0 in the loop, so y1 < y2
. This is fine because you use
for y in range (y1,y2)
In the second part, y3
is set to h
(128 in your case, I guess) and y4
increases from 0 in the loop, so y3 > y4
. This is NOT fine because you use
for y in range (y3,y4)
You could try stepping backwards by giving range()
a third parameter indicating a step size of -1. Or you could switch y3
and y4
(be cautious of what this does to the rest of your code).