why here the output of my_func
is None? I assign an integer to x
then I have an expression in local scope.
Def my_func():
x=4
x**2
Print(my_func())
Output: None
If you don't write any return statement then the function returns None
So you return the value you want to print or else print it in the function itself or else use lambda function as follows
print((lambda x: x**2)(4))
So simple right!! Have a look at OOPS concepts and lambda functions of Python to know more
Thank You!