applied the same code but not getting the addition output during authentication
Decorators,, not getting the output as desired applied the same code but not receiving the addition output during authentication
Can you please share your code.
users = {‘bhavya’:‘123’,‘ram’:‘baam’}
def login_req(func):
def wrapper(username,password,*args,**kwargs):
if username in users and users[username]==password :
func(*args,**kwargs)
else:
print(‘Authentication failed’)
return wrapper
def add(a,b):
return a+b
password_protected = login_req(add)
print(password_protected)
password_protected(‘bhavya’,‘123’, 4 , 6)
Since your add function just returns a+b, instead you can just use print(a+b)