+ 1

where is none coming from

It outputs the input as uppercased but also outputs None https://code.sololearn.com/cv2q87mOHnj5/?ref=app

3rd Sep 2020, 9:43 AM
Shuarma
Shuarma - avatar
6 Respuestas
3rd Sep 2020, 9:59 AM
Slick
Slick - avatar
+ 2
Slick https://code.sololearn.com/cX3xYdWucb6g/?ref=app It works now thank you! i didn't realize that you could use another return
3rd Sep 2020, 10:16 AM
Shuarma
Shuarma - avatar
+ 2
text = input() def uppercase_decorator(func): def wrapper(t): # you just needed a small change return func(t.upper()) return wrapper @uppercase_decorator def display_text(txt): return txt print(display_text(text))
3rd Sep 2020, 10:37 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
probablly because within one of those functions you didnt show, theres a call to print. So it prints. But it doesnt return anything so when you call it at the end, you print what is returned, wich is None
3rd Sep 2020, 9:46 AM
Slick
Slick - avatar
+ 1
I don't understand lmao, is it like it prints something but doesn't return anything?
3rd Sep 2020, 9:55 AM
Shuarma
Shuarma - avatar
+ 1
Nice! And yeah its a bit weird, i just like to think of returning as grabbing a value and leaving the function. If you have a nested function like your decorator, you can use return to grab a value and exit each function that is nested if you decide to do so!
3rd Sep 2020, 10:21 AM
Slick
Slick - avatar