DEV Community

Iano Njuguna
Iano Njuguna

Posted on

How to return nothing in Python?

To literally return 'nothing' use pass, which basically returns the value None if put in a function(Functions must return a value, so why not 'nothing'). You can do this explicitly and return None yourself though.

So either:

if x>1: return(x) else: pass 

or

if x>1: return(x) else: return None 

Top comments (0)