Python NoneType object is not callable (beginner)

前端 未结 4 1753
傲寒
傲寒 2020-12-04 14:25

It tells me line 1 and line 5 (new to debugging/programming, not sure if that helps)

def hi():
    print(\'hi\')


def         


        
4条回答
  •  猫巷女王i
    2020-12-04 15:04

    You want to pass the function object hi to your loop() function, not the result of a call to hi() (which is None since hi() doesn't return anything).

    So try this:

    >>> loop(hi, 5)
    hi
    hi
    hi
    hi
    hi
    

    Perhaps this will help you understand better:

    >>> print hi()
    hi
    None
    >>> print hi
    
    

提交回复
热议问题