From 76f6536b4fd47149e1af4c932cfea76bb80aa68a Mon Sep 17 00:00:00 2001 From: benpeterdalley Date: Sun, 14 Oct 2018 07:54:51 +1100 Subject: [PATCH] Update index.md (#18703) Included info about the colon being required and no closing statement, and indentation everything that is properly indented following the definition is within the scope of the function --- .../pages/guide/english/python/defining-functions/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/pages/guide/english/python/defining-functions/index.md b/client/src/pages/guide/english/python/defining-functions/index.md index 533d6d8619..189a1a6102 100644 --- a/client/src/pages/guide/english/python/defining-functions/index.md +++ b/client/src/pages/guide/english/python/defining-functions/index.md @@ -17,6 +17,8 @@ We can create a function that writes the Fibonacci series to an arbitrary bounda ... fib(2000) 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 -The [`def`](https://docs.python.org/3/reference/compound_stmts.html#def) keyword introduces a function definition. It must be followed by the function name and the parenthesized list of formal parameters. The statements that form the body of the function start at the next line and must be indented. +The [`def`](https://docs.python.org/3/reference/compound_stmts.html#def) keyword introduces a function definition. It must be followed by the function name and the parenthesized list of formal parameters, followed by a colon. The statements that form the body of the function start at the next line and must be indented. The first statement of the function body can optionally be a string literal; this string literal is the function's documentation string, or [docstring](https://www.python.org/dev/peps/pep-0257/) (More about docstrings can be found in the section Documentation Strings). Some tools use docstrings to automatically produce online or printed documentation or to let the user interactively browse through code. It's good practice to include docstrings in code that you write, so try to make a habit of it. + +No closing statement is required for the function (eg something similar to Ruby's END), all code that is indented following the opening definition is within scope of the function.