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))

30th Dec 2021, 7:56 AM
Roman-Maria Höritzsch
2 odpowiedzi
+ 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()
30th Dec 2021, 8:30 AM
Atul
Atul - avatar
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))
21st Nov 2022, 3:02 AM
Rihan Dsouza