Python Function Returning None

后端 未结 5 1968
一整个雨季
一整个雨季 2020-11-22 08:12

My very simple python function is returning \'None\' at the end of it and I\'m not sure quite why. I\'ve looked at some other posts and still can\'t figure it out. Any help

5条回答
  •  清酒与你
    2020-11-22 09:04

    You are not returning anything in the function printmult, therefore when you print the result of printmult(30) it will be None (this is the default value returned when a function doesn't return anything explictly).

    Since your method have a print statement inside and it's not supposed to return something (usually when a method names is something like printSomething(), it doesn't return anything), you should call it as:

    printmult(30)
    

    not

    print(printmult(30))
    

提交回复
热议问题