0
Help to find mistake pls
Its all about this lesson def decor(func): def wrap(): print("============") func() print("============") return wrap def print_text(): print("Hello world!") decorated = decor(print_text) decorated() the outputs are beautiful ============ Hello world! ============ While I tried to repeat my self with code def func_main(func1): def sub_func(): print("***********") print(func1) print("***********") return sub_func def print_smth(): print("Hello everybody!") decor = func_main(print_smth) decor() It runs with shitty: *********** <function print_smth at 0x1067981e0> *********** What am I doing wrong?
3 Respuestas
+ 4
Instead of :
print("**********"')
print(func1)
print("**********"')
It should be:
print("**********"')
func1()
print("**********"')
Max Rubs It's printing those weird text coz you're printing the function instead of calling it.
Here's a working code:
https://code.sololearn.com/cdSRSbyiz9Nh/?ref=app
+ 3
And next time, please post the code link instead of copy pasting the whole code.👍
That way, we can easily debug it.
+ 1
Thank you, sir!