Build my own Hello World

It's just a personal note.

What Python outputs when return no value

What's this?

  • I've implemented what Python outputs when it returns no value.

What I learned

I became curious about this topic when solving the university's quiz.

Below are the outputs of several sample patterns.
From this, I realize that Python outputs "None" automatically if no value is designated to return.

def pass_with_no_return():
  pass

def return_none():
  return None

def return_return():
  return

# whether those functions can work
pass_with_no_return() # pass
return_none() # pass
return_return() # pass

# what value those functions output
print("pass_with_no_return: ", pass_with_no_return()) # => pass_with_no_return:  None
print("reutrn_none: ", return_none()) # => reutrn_none:  None
print("return_return: ", return_return()) # => return_return:  None