Butters Butters - 1 year ago 152
Python Question


Can we pass two arguments in the function that returns true and filters a list?
I am trying to get divisor from user and dividend be picked up from the list.

print "Get the divisor"

h=lambda x,divisor: x%divisor==0
print ans

Answer Source

Yes, you can, if you have divisor defined in the surrounding scope.

But then, you will not need to use it as an argument any longer:

divisor = int(raw_input())
ans = filter(lambda x: x % divisor==0, new_list)
print ans
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download