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 Réponses
+ 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