Site menu

CodeCook.io

  • Languages
    • C
    • C++
    • CSS
    • Git
    • HTML
    • Java
    • JavaScript
    • jQuery
    • PHP
    • Python
    • Ruby
    • Scala
  • list
  • prepend

Python - Prepend item to list

Add item to front of a list. Either a new list is created or the current list is modified.

1
7918
  • Share on Facebook
  • Share on Google+
  • Share on Twitter
Using concatenation
[{{item}}] + {{list}}
python

Notes

  • Original list is NOT modified
[list]

last update: Feb. 8, 2015

0
7938
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Insert element at index 0 (start) of list.

Using insert
{{list}}.insert(0, item)
python
  • List operations

Notes

  • Original list is modified
None [None]

last update: Feb. 8, 2015

Advertisement

This project is hosted on DigitalOcean, try it and support us

Similar

  • Prepend item to array

Related concept

  • Apply function to list
  • Create a list of integers
  • Sort list of numbers

Random task

  • Select element by data attribute
  • Add public SSH key to remote server
  • Loop until condition is true
  • Check console available
  • Key value item count
  • Blog
  • About
  • License