* 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
538 B
538 B
title
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
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
.