I recently started learning Python 3.5.1, and am currently experimenting with lambda expressions. I tried setting up the simple method below.
def sum_double(a, b):
return lambda a, b: a+b if a != b else (a+b)*2, a, b
All it is supposed to do is return the sum of a and b, and twice their sum if a is equal to b, but instead I get an output that looks like this.
Code:
print(sum_double(1, 2))
print(sum_double(2, 3))
print(sum_double(2, 2))
Output:
(<function sum_double.<locals>.<lambda> at 0x000001532DC0FA60>, 1, 2)
(<function sum_double.<locals>.<lambda> at 0x000001532DC0FA60>, 2, 3)
(<function sum_double.<locals>.<lambda> at 0x000001532DC0FA60>, 2, 2)
Am I doing this wrong? Why is this happening, and how would I use a lambda expression to achieve my desired functionality if that is even possible?