# Defined function not printing

``````def analytisch(x ,v ,a, t):

a = v/t
v = x/t
x = v*t

print(analytisch(x,v,a,t))
print('x = ',x)

return a, v, x, t
``````

Hello, I’ve been struggling for a while with this. There is no output and no error so I don’t know what to do.

this is inside the function, and would cause an infinite recursion

you need to call your function outside the function itself for it to execute

Then I get this error: NameError: name ‘x’ is not defined

1 Like

you need to call the function with some values - what should those be? numbers?

then `analytisch(1,2,3,4)` or something

the only known variable is t which is 8.5

I got a result’None’
Process finished with exit code 0

I feel something wrong with your parameter definition

There are a few things here.

Let’s go line by line…

1. Define a function with some variables. None of them are given any value yet.
2. Divide v by t and assign the result to a variable a.

This is important…
What happens when v or t are 0?
What happens when v or t are not even numbers?
What happens, when they are not given a value?

1. Same as line above, but with different variables.
2. Same as line above, but with different variables.
3. Print the result of a function.

This is not good. Think about it: you try to print the result of a function (‘return value’ of a function). To print that value, you need to execute the function line-by-line and get to the line which ‘returns’ something.
So we execute the function ‘analytisch’, and go to line number 1, line nuber 2, etc., then we try to print result of the function again… So we execute a function, go to line 1, line 2 …
Do you see where it is going?
It creates an infinite loop. It is called recursion, can be useful, but it is too advanced for you right now.
Do not use that line. Try to use something like
`print(a)`
`print(b)`

1. Print a string and a variable. All good here.
2. Return 4 variables. Looks okay, I prefer to use return like that `return(a,b,c)`

Thanks for the explanation by using ` t = np.linspace(t0, t1, 1 + round((t1 - t0) / dt))` instead of `t=9`. It now works