Python Function Returning None

后端 未结 5 1966
一整个雨季
一整个雨季 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

    Because in Python, every function returns a value, and None is what is returned if you don't explicitly specify something else.

    What exactly did you expect print(printmult(30)) to do? You've asked it to evaluate printmult(30), and then print whatever results from that. Something has to result from it, right? Or were you maybe expecting some kind of exception to be raised?

    Please be sure you understand that printing and returning are not the same thing.

提交回复
热议问题