Important Notice:

Function Without return

Function Without return

25 views 1 min read

Function Without return :-

 यदि किसी function में explicit return statement नहीं लिखा जाता है, तो Python function के समाप्त होने पर अपने आप None return करता है।

English : If a function does not contain an explicit return statement, Python automatically returns None when the function finishes.

Example:

def show():
    print("Hello Python")

result = show()
print("Returned Value:", result)

Output:

Hello Python
Returned Value: None

Explanation:

  • print("Hello Python") message को screen पर display करता है।

  • Function में explicit return statement नहीं है।

  • इसलिए show() का returned value None होता है।

  • result variable में None store होता है।

Important: return बिना value के भी लिखा जा सकता है। return और return None दोनों function से None return करते हैं और function को समाप्त कर देते हैं।

Example 2:

def demo():
    return

print(demo())

Output:

None

Related Notes