When I write my function like this, it works perfectly:
a = [(9,0), (6,6), (1,15), (243, 635), (9, 7), (7,8), (2,4)]
def func(a)
#function calculation
return Min dist
But this function is not very feasible since it will only calculate the given ‘a’ within the code. Is there a way to make the function recognize ‘a’ as a list containing however many points the user inputs? For example, I want the function to work like this:
def func(a)
#calculation
return Min dist
In console:
[In:] a = [(9,0), (6,6), (1,15), (243, 635), (9, 7), (7,8), (2,4)]
[O:] 3.436788
答案 0 :(得分:1)
是的,你已经可以:
def func(a)
#function calculation
return Min dist
a = [(9,0), (6,6), (1,15), (243, 635), (9, 7), (7,8), (2,4)]
b = [(9,0), (6,6), (1,15), (243, 635), (9, 7), (7,8), (2,4)]
c = [(9,0), (6,6), (1,15), (243, 635), (9, 7), (7,8), (2,4)]
func(a)
func(b)
func(c)