I have an array of strings that looks something like this 

```
['a', 'b', 'c.1', 'c.2', 'c.3', 'c.4', 'd.1', 'd.2', 'd.3']

```

I want to break this into something like

```
[['a', 'b', 'c.1'], ['a', 'b', 'c.2'], ['a', 'b', 'c.3'],
 ['a', 'b', 'd.1'], ['a', 'b', 'd.2'], ['a', 'b', 'd.3'],
 ['a', 'b', 'd.4']]

```

How do I go about doing this ? My Idea was to use groupby in itertools
to get something like 

```
['a', 'b', ['c.1', 'c.2', 'c.3'], ['d.1', 'd.2', 'd.3', 'd.4']]

```

and then probably something like

```
result = []
for elem in nestedList:
    if isinstance(elem, list):
        temp = []
        for elem in nestedList:
            if not isinstance(elem, list):
                temp.append(elem):
        temp.append(elem)
    result.append(temp)

```

In order to do that I would need to access the next element in groupby 

```
(Something like lambda x: '.' not in x and nextelement.split('.')[0] != x)

```

How do I do that?