Open in TheBrain

RETURN python

<p>Feb 10, 2013 12:36 PM

&#160;

note... ONLY use return inside a function for example:

&#160;

def foo():

&#160;&#160;&#160;&#160;While True:

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return False

&#160;

&#160;

do NOT use it in a control statement,

&#160;

eg &#160;I tried to do

&#160;

if 5 in [3,4,5]: return 5

&#160;

that generates an error: &#160;'return' outside function !!!

(meaning that you have used it outside of a function definition)

&#160;

correct usage is if 5 in [3,4,5]: 'foo'

&#160;

&#160;</p>