In this chapter let us create a function based on another function with the python lambda function!
Let’s say you want to create a seed value that will be used to find the modulo with another value then you will create the function below with the help of the lambda anonymous function.
def modfunc(n): return lambda a : n % a
Now you can call the above function and use the lambda anonymous function to perform the modulo operation.
myfunction = modfunc(12) print(myfunction(5))
Basically the above is equal to 12 % 5 which is equal to 2.
This is the last tutorial of the Python beginner series, I might continue to write more python tutorials in the future that will deal with more complex python modules such as the Math and the RegEx module but for the python basic part, I think I have covered almost everything that you will need to start writing your own python program! Don’t forget to share the entire tutorial series with your friend to show your appreciation of my hard work.