How to take a function as input in Python