Tools, FAQ, Tutorials:
'return' Statement in Function Statement Block
How to use the "return" statement in a function statement block in Python?
✍: FYIcenter.com
The "return" statement can be used in a function statement block to terminate the execution of the function and return a data object to the calling expression.
Here is a good example of "return" statement used in a function statement block:
>>> def fib(n): ... """Return a Fibonacci series up to n.""" ... out = [] ... a, b = 0, 1 ... while a < n: ... out.append(a) ... a, b = b, a+b ... else: ... return out ... >>> fib(2000) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]
⇒ Function Calling Expressions
⇐ 'def' - Function Definition Statements
2018-02-28, 1257🔥, 0💬
Popular Posts:
How to troubleshoot the Orderer peer? The Docker container terminated by itself. You can follow this...
Can You Specify the "new line" Character in Single-Quoted Strings? You can not specify the "new line...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encod...
What validation keywords I can use in JSON Schema to specifically validate JSON Array values? The cu...