I have written the below code using decorator and the code is returning None when I am expecting an integer or float value. the function (num(a, b)) returns a value when I don't use decorator and the issue comes when I use decorator. Can someone please clarify why the code is returning None. Below is the code:
def decor(func):
def inner(a, b):
if a <= b:
print("If executed")
a, b = b, a
c = a - b
print(c)
return c
else:
print("else executed")
func(a, b)
return inner
def num(a, b):
print("Function executed")
d = (a - b)
print(d)
return d
num = decor(num)
print(num(3, 5)) # this is returning a value
print(num(3, 1)) # this is returning None