Home > Back-end >  why returning None in functions python?
why returning None in functions python?

Time:05-10

first image I was having problem when I run this code I raise exception in function then why none is printing

sec image And in this case none is not printing.. pls help

CodePudding user response:

when a python function does not have a return statement it automatically return None.

In the first image, the print(numcheck(5)) pass the assert but the function return None so it printed None but print(numcheck(-5)) did raise the exception.

In the second image print(numcheck(-5)) raise directly the exception so python did not print anything.

  • Related