decorator is printing none at the end? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

decorator is printing none at the end?

#please tell me why none is getting printed at the end of the program? def decor(func): def wrap(): print("first line") func() print("second line") return wrap def print_text(): print("Hello world!") decorated = decor(print_text) print (decorated())

17th Jul 2018, 8:45 AM
Kushagra Verma
Kushagra Verma - avatar
2 Answers
+ 4
Maybe make this the last line: decorated() You are already printing everything in the functions. The last line doesn't need a print statement.
17th Jul 2018, 10:29 AM
Paul
Paul - avatar
0
You are not returning anything from the function print_text, that is the reason behind None. Solution should be you can return from the print_text function or remove the print from this line print (decorated()).
21st Jul 2018, 5:10 PM
$ยข๐Žโ‚น๐”ญ!๐จ๐“
$ยข๐Žโ‚น๐”ญ!๐จ๐“ - avatar