No, not really.
Here’s a better example:
```python
def list_even(x):
even = []
for n in x:
if not n %2:
even.append(n)
return even
numbers = [2,3,4,6,8,101,103,111,120,124]
print(list_even(numbers))
```
Not a worry; I think I can work with it.
You’re using myfunc as both the name of your function and the operator for the for loop; not good.
Also, to call the function, you need to use the name of said function. Maybe I confused you by including it in the print function call.
So, you’ll need print(myfunc(numbers))
The reason I named the function list_even is that the name is descriptive of what the function is doing.
The name I’ve used, such as x, was also not too helpful; sorry.
What that does: the x in the function holds the list of numbers that has been passed to it, as in list_even(numbers) The list of numbers is passed to the function, which can use that list, which is held in the a local variable, x. You can see this if you put a print call in the function:
def myfunc(x):
print(x)
numbers = [2,3,4,6,8,101,103,111,120,124]
myfunc('Hello')
myfunc(101)
myfunc(numbers)