I am naming the x and y coordinates for the two cities separately and making them smaller for readability:
#addLine(map,cityXCoordinate[city],cityYCoordinate[city],
#cityXCoordinate[city], cityYCoordinate[city])
cityXCoordinate1= x1
cityYCoordinate1 = y1
cityXCoordinate2 = x2
cityYCoordinate2 = y2
In this case I am not repainting the image, but creating a second image, so the first is not overwritten, that's your choice.
#Find the max height and width of your map
w= getWidth (map)
h = getHeight(map)
newPic = makeEmptyPicture(w,h)
#loop through the coordinates of the map
for y in range (0,h):
for x in range (0, w):
#select the points forming a straight line between the two points
if (x==((y-y1)*(x2-x1)/(y2-y1)+x1)):
newPxl= getPixel(newPic,x,y)
#color those pixels black
color = makeColor(0,0,0)
setColor (newPxl, color)
else:
#color the remaining map as it is
pxl = getPixel(pic, x, y)
newPxl= getPixel(newPic,x,y)
color = getColor(pxl)
setColor (newPxl, color)