From 444fcbd578f6e2e0252122288d4a8e41b4203502 Mon Sep 17 00:00:00 2001 From: JawnsenTrain <44305457+JawnsenTrain@users.noreply.github.com> Date: Mon, 11 Feb 2019 15:39:33 -0600 Subject: [PATCH] Created a file for the insert method (#26496) * Created a file for the insert method I tried to adopt your style of making these files in order to retain consistency. * Rename list-insert-method to list-insert-method.md * Rename guide/english/python/lists/list-insert-method.md to guide/english/python/lists/list-insert-method/index.md * Added code formatting, changed more info link --- .../python/lists/list-insert-method/index.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 guide/english/python/lists/list-insert-method/index.md diff --git a/guide/english/python/lists/list-insert-method/index.md b/guide/english/python/lists/list-insert-method/index.md new file mode 100644 index 0000000000..ba67532b1b --- /dev/null +++ b/guide/english/python/lists/list-insert-method/index.md @@ -0,0 +1,23 @@ +--- +title: List Insert Method +--- +## List Insert Method + +The method `insert(i,x)` inserts a given value `x` into the list at index `i`. The index must be within the bounds of the list +(from `0` to the length of the list minus 1). + +#### Example Usage + +```py +numbers = [1, 2, 3, 4, 5] +numbers.insert(3,8) +print(numbers) +``` +#### Output +``` +[1, 2, 3, 8, 4, 5] +``` +The value `8` is inserted into the list at position `3`. + +#### More Information: +- [Python Docs: Lists](https://docs.python.org/3.6/tutorial/datastructures.html#more-on-lists)