マップ上のポイント間に線を引く必要がある課題に取り組んでいます。if文で作ったのですが、それだとできる回数が限られるのでループを使いたいです。
これまでのコードは次のとおりです。都市を追加して線を引くことができますが、開始点から次の点までではなく、それ自体に線を引きます (そして続行します)。
誰でも助けてもらえますか?
def level1():
cityXvalue = [45,95,182,207,256,312,328,350,374,400]
cityYvalue = [310,147,84,201,337,375,434,348,335,265]
# Display the map image
map = makePicture(getMediaPath("map.png"))
show(map)
number = 0
# Ask user to enter numbers of the cities they wish to visit
cities = requestInteger("Enter the number of the city you would like to visit")
# Draw a line between previously entered point and current one
while cities > number:
city = requestInteger("Please choose a city number")
addLine(map,cityXvalue[city],cityYvalue[city], cityXvalue[city], cityYvalue[city])
repaint(map)