.insert()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published May 5, 2021Updated Sep 3, 2021
Contribute to Docs

Adds an item at a specified index in the list.

Syntax

list.insert(index, item)

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:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy