0
"Decorators 2 - uppercasing" practice - I am lost
Somehow I just can't bend my mind around this decorator thing. So far everything was logical and easy, but I am stuck at this practice for two days now. Just dont know how this is supposed to work... -- text = input() def uppercase_decorator(func): def wrapper(text): text = text.upper() print(text) return wrapper @uppercase_decorator def display_text(text): return(text) print(display_text(text))
2 Respostas
+ 5
https://code.sololearn.com/cXIiHbEfRf1N/?ref=app
explanation : Decorators provide a way to modify functions using other functions.
in your code u are not returning anything in that "wrapper function" the solution is pretty simple u just have to return text.upper()
0
text = input()
def uppercase_decorator(func):
def wrapper(text):
#your code goes here
return text.upper() #this will return the text in uppercase
return wrapper
@uppercase_decorator
def display_text(text):
return(text)
print(display_text(text))