.insert()

Adds an item at a specified index in the list.

Syntax

Loading...

The .insert() method takes in two parameters:

  • The index that you want to insert into.
  • The item that you want to insert at the specified index.

Example

To add an item at index 2 of store_line list:

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy