+ 1
where is none coming from
It outputs the input as uppercased but also outputs None https://code.sololearn.com/cv2q87mOHnj5/?ref=app
6 Respuestas
+ 1
Take a look at this thread
https://www.sololearn.com/Discuss/2451718/?ref=app
+ 2
Slick
https://code.sololearn.com/cX3xYdWucb6g/?ref=app
It works now thank you! i didn't realize that you could use another return
+ 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))
+ 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
+ 1
I don't understand lmao, is it like it prints something but doesn't return anything?
+ 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!