Akash RP
Akash RP

Reputation: 61

NoneType object is not callable in nested function python

I am beginner to Python, i am trying this follwing code but i cant understand the error

def make(label):
    def echo(message):
        print(label+':'+message) 


make('Message')('Hi')

I expect the output to be Message:Hi but it showing an error 'NoneType object is not callable

Upvotes: 0

Views: 243

Answers (1)

Dev Khadka
Dev Khadka

Reputation: 5471

you need to return the echo function

def make(label):
    def echo(message):
        print(label+':'+message) 
    return echo

make('Message')('Hi')

Upvotes: 2

Related Questions