小编And*_*car的帖子

为什么我在代码中收到"列表索引超出范围"?

我收到"列表索引超出范围".我想我正在错误地命名其中一个变量.如果我在其中添加其余内容可能会更有意义.

我试图打印出列表中坐标的差异.我确定它搞砸了str(distance_list[i]).

相关代码:

# Get the maximum distance from the user
maxDistance = float(raw_input("What is the maximum distance from the base?"))

# Set the base N,E values
#baseEasting = float(raw_input("What is the easting of the base?"))
#baseNorthing = float(raw_input("What is the northing of the base?"))
baseEasting = "346607"
baseNorthing="6274191"

#TODO: Place the values for meterological stations into the lists
stationCoords = [ [476050, 7709929],[473971,7707713],[465676,7691097] ,[515612,7702192] ,[516655,7704405],[519788,7713255],[538466,7683341] ]
numCoords = len(stationCoords)

distance_list = []
for i in range (0, …
Run Code Online (Sandbox Code Playgroud)

python indexing error-handling list range

2
推荐指数
1
解决办法
88
查看次数

标签 统计

error-handling ×1

indexing ×1

list ×1

python ×1

range ×1