print(type((lambda x, y, z: int((x + y + z)/3))(10, 11, 12)))
In the above code, I have used int() annotation but as per the python documentation, lambda functions cannot contain annotations. Then why am I not getting any error when using an annotation?
intin your lambda is part of the expression it evaluates when called: It computes something with x,y and z and passes the result toint()to return an integer result at the end.intas a type annotation. You're using to to create anint-type object initialised with a value supplied within the brackets.intkeyword CAN be used to type annotate but it is NOT used as a type annotation here, it is used as a function to cast the parameter to theinttype.