+ 2

What is wrong in this code ??

def work_for_all(func): def inner(*args, **kwargs): print("I can decorate any function") return func(*args,**kwargs) return @work_for_all def div(a,b): return a/b #to run div(2,8)

28th Aug 2018, 10:50 AM
đŸŒ·â“â“€đ”č𝓝ⓐ â“€â“—đ”žâ“đŸŒ·
đŸŒ·â“â“€đ”č𝓝ⓐ â“€â“—đ”žâ“đŸŒ· - avatar
1 RĂ©ponse
+ 9
# Amended version def work_for_all(func): def inner(*args, **kwargs): print("I can decorate any function") return func(*args,**kwargs) return inner @work_for_all def div(a,b): return a/b print(div(2,8)) # Basically, something had to be returned in line 7 as well as your command should actually be printing, not just doing the calculation. # Or, you can embed the printing into the decorator function, your call.
28th Aug 2018, 8:15 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar