Question: Consider I have these lists:

```
l = [5,6,7,8,9,10,5,15,20]
m = [10,5]

```

I want to get the index of `m` in `l`. I used list comprehension to do that:

```
[(i,i+1) for i,j in enumerate(l) if m[0] == l[i] and m[1] == l[i+1]]

```

Output : `[(5,6)]`

But if I have more numbers in `m`, I feel its not the right way. So is there any easy approach in Python or with NumPy? 

Another example:

```
l = [5,6,7,8,9,10,5,15,20,50,16,18]
m = [10,5,15,20]

```

The output should be: 

```
[(5,6,7,8)]

```

Answer: 
Just making the point that @MSeifert's approach can, of course, also be implemented in `numpy`:

```
def pp(h,n):
    nn = len(n)
    NN = len(h)
    c = (h[:NN-nn+1]==n[0]).nonzero()[0]
    if c.size==0: return
    for i,l in enumerate(n[1:].tolist(),1):
        c = c[h[i:][c]==l]
        if c.size==0: return
    return np.arange(c[0],c[0]+nn)

```

[![enter image description here](https://i.stack.imgur.com/nok9q.png)](https://i.stack.imgur.com/nok9q.png)
```
def get_data(l1,l2):
    d=defaultdict(list)
    [d[item].append(index) for index,item in enumerate(l1)]
    print(d)

```

Using **defaultdict** to store indices of elements from other list.