T
Thomas Philips
To experiment with filtering, I define a function f(x,k) as follows return x%k==0
I can check that it works by typingFalse
Now, I try to filter a range using
Traceback (most recent call last):
File "<pyshell#16>", line 1, in -toplevel-
filter(f(k=3),range(20))
TypeError: f() takes at least 1 non-keyword argument (0 given)
I next try
Traceback (most recent call last):
File "<pyshell#17>", line 1, in -toplevel-
filter(f(3),range(20))
TypeError: 'bool' object is not callable
But, as k defaults to 2, I get exactly what I expect from
What's wrong with my syntax when passing the parameter k=3?
Sincerely
Thomas Philips
I can check that it works by typingFalse
Now, I try to filter a range using
Traceback (most recent call last):
File "<pyshell#16>", line 1, in -toplevel-
filter(f(k=3),range(20))
TypeError: f() takes at least 1 non-keyword argument (0 given)
I next try
Traceback (most recent call last):
File "<pyshell#17>", line 1, in -toplevel-
filter(f(3),range(20))
TypeError: 'bool' object is not callable
But, as k defaults to 2, I get exactly what I expect from
filter(f,range(20)) [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
What's wrong with my syntax when passing the parameter k=3?
Sincerely
Thomas Philips