python add to first element of list code example
Example 1: python list add first
# list.insert(before, value)
list = ["a", "b"]
list.insert(0, "c")
print(list) # ['c', 'a', 'b']
Example 2: append first to list pythno
array.insert(0,var)
# list.insert(before, value)
list = ["a", "b"]
list.insert(0, "c")
print(list) # ['c', 'a', 'b']
array.insert(0,var)