だから私は基本的にこれを3回ループさせたいm
. では、なぜこれが範囲外なのですか?
Python の正確なエラー リターン:
choices[r]=p.nextInt()
IndexError: list assignment index out of range
p.next
独自のモジュールがあるため、uni でこのように記述する必要があるため、無視してください。
これが私のコードです
cities=["Coventry", "Birmingham", "Wolverhampton", "Leicester"]
distances=[
[0,25,33,24],
[25,0,17,42],
[33,17,0,54],
[24,42,54,0]]
def distancesthree():
choices=[0,1,2]
for m in range(3): #This will loop three times!
for r in range(len(cities)):
p.write ("%d : %s\n" %(r, cities[r]))
p.write("\nEnter city number %d: \n"%(m+1))
choices[r]=p.nextInt()