if d<r:
vx,vy,ax,ay=0,0,0,0
return [vx,ax,vy,ay]
This isn’t a function so you can’t use return
. If you want to add those values to a list you can make a new list:
new_list = [vx,ax,vy,ay]
You don’t need to use return outside of a function because those variables are already in scope. When you use variables inside a function they aren’t in the same scope as the rest of your program. For example:
>>> def foo():
a =10
>>> a = 1
>>> foo()
>>> a
1
The a
inside the function doesn’t effect the a
outside of. In you if
statement you don’t need a return
because it is in the same scope. The assignment of the variables doesn’t need to be returned from anywhere because it’s the same scope.
And as @Hugh Bothwell pointed out you have a typo in your function call should be:
scipy.integrate.odeint()
solved Code not working (python) [closed]