Question: I am trying to replace items in list of lists by the value of the index of that specific list. I can do it with a for loop, but I was wondering if there is a faster way to do this.

such that the following list

```
example = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

```

becomes:

```
solution = [[0, 0, 0], [1, 1, 1], [2, 2, 2]]

```

Answer: 
```py
solution = [[i]*len(x) for i, x in enumerate(example)]

```
Here is a solution with the `map` function:

```
res = list(map(lambda i : [i] * len(example[i]),
            range(len(example))
        ))
print(res)

```

It's more verbose than the comprehension method, but coming from other languages I prefer it - I find the `map` to be more explicit and easier to follow, as it's built out of the common components of higher-order functions rather than having its own syntax.