From fe2d44a6ad0f532ef088272e13028094a0d98215 Mon Sep 17 00:00:00 2001 From: chris13888 <43319231+chris13888@users.noreply.github.com> Date: Tue, 18 Dec 2018 22:38:27 -0800 Subject: [PATCH] Create overview for Python's enumerate function (#23852) * Rename guide/english/python/index.md to guide/english/python/enumerate/index.md * Created More Info section --- guide/english/python/enumerate/index.md | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 guide/english/python/enumerate/index.md diff --git a/guide/english/python/enumerate/index.md b/guide/english/python/enumerate/index.md new file mode 100644 index 0000000000..39c9869484 --- /dev/null +++ b/guide/english/python/enumerate/index.md @@ -0,0 +1,29 @@ +--- +title: Python's Enumerate Function +--- + +## Overview +`enumerate()` is a built-in function in Python. It is useful for iteration over a list or any other iterable. + +## Arguments +`enumerate()` requires an iterable, and `start` as an optional parameter (it defines where the indexing starts). + +## Return Value +Returns an enumerate object. If you call `list()` on it, you can see that each item in the object is a tuple – an index followed by the item in the iterable. + +## Usage Example + animals = ['cat', 'dog', 'rabbit', 'fox', 'wolf'] # A list of animals. + for index, item in enumerate(animals, start=20): + print(index, item) +### Output + 20 cat + 21 dog + 22 rabbit + 23 fox + 24 wolf + +Try it out! + +#### More Information + +- Python's Docs