Decorator:Authenticator

Run Settings
LanguagePython
Language Version
Run Command
# Create an @authenticated decorator that only allows the function to run is user1 has 'valid' set to True: user1 = { 'name': 'Sorna', 'valid': False #changing this will either run or not run the message_friends function. } def authenticated(fn): # code here def wrapper(*args, **kwargs): if args[0]["valid"]: print(args[0]["valid"]) return fn(*args, **kwargs) else: return print("invalid user") return wrapper @authenticated def message_friends(user): print("message has been sent") message_friends(user1)
Editor Settings
Theme
Key bindings
Full width
Lines