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, ∼1750🔥, 0💬
Popular Posts:
How To Create an Array with a Sequence of Integers or Characters in PHP? The quickest way to create ...
What are "*..." and "**..." Wildcard Parameters in Function Definitions? If you want to define a fun...
How to detect errors occurred in the json_decode() call? You can use the following two functions to ...
How to use the JSON to XML Conversion Tool at freeformatter.com? If you want to try the JSON to XML ...
How To Access a Global Variable inside a Function? in PHP? By default, global variables are not acce...