How to add an element to the front of a list in Python

Adding an element to the front of a list inserts the element at index 0, shifting the other elements to the right. For example, adding “a” to the front of [“b”, “c”] results in [“a”, “b”, “c”]

Solution for How to add an element to the front of a list in Python : You can use list.insert() to add an element to the front of a list Call a_list.insert(index, object) on a_list with 0 as index to insert object at the front of a_list.


how-to-add-an-element-to-the-front-of-a-list-in-python