[Tutor] Anonymous function

Devanshu Nalavade perseus1702 at gmail.com
Wed Mar 16 20:00:32 EDT 2022


Respected Tutor,

I have written a code that finds the sum of numbers passed as arguments in
a user-defined function. This function has an anonymous function that takes
the same arguments and does the summation. However for some reason the code
is not giving me the desired output, there are no syntax errors so I'm not
understanding what I'm doing wrong.
Your help is much appreciated, the program I wrote is as follows:

>>>def sum(arg1,arg2,arg3=10):
  ...  m = lambda arg1,arg2,arg3:arg1+arg2+arg3

>>>print(sum(5,6))

The output comes out as 'None'

Thanks and Regards,
Devanshu Nalavade


More information about the Tutor mailing list