I'm new to python and I was wondering how you would group a text file by a single word. For example say my text file looks like this:

```
eggs monday $5 john
bread monday $3 harry
bananas wednesday $2 john
milk saturday $4 sally
tomatoes sunday $7 sally

```

In my case I want to group the file by names. So for John, for example, I want it to be shown like so:

```
[john,[eggs,monday],[bananas,wednesday]]

```

and so on for harry and sally. 

So right now my code looks like this and I've been able to identify the necessary things (namely name, item, and day) but I'm confused as to how I can group it.

```
def grocery():
    file = open('shopping.txt')

    wholelist = []
    innerlist = [] 

    for line in file:
        lines = line.split()
        name = lines[3]
        item = lines[0]
        day = lines[1]

```

Thank you in advance. Also I am limited to using a list within a list so I'm not allowed to use dictionaries.