0

when i run the code i get a memory location as an output

<function at 0x00000200FF8A5E50>

val = (lambda colmns:(colmns.max + colmns.min)/2
print(val)
hghebrem
  • 5
  • 2

1 Answers1

0

A lambda is just an anonymous function object and that's why it prints that way. In fact, as soon as you assign it to a variable... then why have a lambda in the first place? Might as well do

def foo(colmns): 
    return (colmns.max + colmns.min)/2

And then it wouldn't be too surprising that print(foo) is <function 0x...>.

tdelaney
  • 73,364
  • 6
  • 83
  • 116
  • @hghebrem - what are you talking about? The thing you seemed to have missed is that lambda creates a function object, and that's what I illustrated with the `def`. But I still needed to wrap that back specifically to the question about where "" comes from. When you see it as a `def` I didn't think there would be any question about why is printed as a "function". – tdelaney Jul 22 '22 at 18:12