Question: I am working on some project, and it requires me to do something like this

```
[10, 15, 17, 18]
->
[10, 12, 15, 17, 18]

```

Like this, I need to put an element in between of two elements. I did try

```
mylist = [10, 15, 17, 18]
mylist.append(mylist[-1])
for i in range(2):
    mylist[-1 * i - 2] = mylist[-1 * i - 3]
mylist[-4] = 12

```

But I don't think this is efficient, and the code will probably be messy if I put this in more sophisticated codes. Is there a function to automatically do this?

Answer: 
You can use the `insert()` method.

The usage is `list.insert(index, element)`

So for your program:

```
mylist = [10, 15, 17, 18]
mylist.insert(1, 12)

```

Will insert the number `12` into the index `1` of your list, which is the second place.
You also need to identify the position where to index, and this could be made thanks to a lambda function.

```py
mylist = [10, 15, 17, 18]

def add_value(my_list, val):
  get_index = lambda z : next(x[0] for x in enumerate(mylist) if x[1] > z)
  ind = get_index(val)
  return my_list.insert(ind, val)

print(add_value(mylist, 12))

```