Thursday 15 January 2015

Is there a way to return literally nothing in python? -


I'm learning Python and I was wondering if I had a way to write a code that does this:

  def f (x): if x> 1: return (x) other: # do not return anything   

I ask about others I'm part of the code x & lt; = 1 , returning any is not acceptable, I do not have to return anything. There is no such thing as "nothing returning" in Python. Every function gives some value (as long as it is not possible).

return statement is used, then Python considers it as returning any .

Therefore, you have your function. Either you should return any any (or some other sensory value) and add appropriate logic to your calling code to find it, or you should take exception (which can catch the calling code if She wants) .

No comments:

Post a Comment