我的目錄的Python類型的字典的迭代列表和創建類型的字典新
[
{'town':'A', 'x':12, 'y':13},
{'town':'B', 'x':100, 'y':43},
{'town':'C', 'x':19, 'y':5}
]
我的出發點是:
x = 2
Y =3
我最大射程:
mxr = 30
我的功能:
def calculateRange (x1, x2, y1, y2):
squareNumber = math.sqrt(math.pow ((x1-x2),2) + math.pow((y1-y2),2))
return round(squareNumber, 1)
如何循環訪問我的名單,並在新的列表推送數據和我的函數的結果,如果calculateRange <的結果=我的最大範圍
我想有最後:
[
{'town':'A', 'x':12, 'y':13, 'r':someting },
{'town':'C', 'x':19, 'y':5, 'r':someting}
]
該函數不是Python。 –
@RafeKettler好吧,我剛剛更改了語法 – OlZ
沒有'math.round()'函數。你的意思是內置'round()'而不是? –