I have 3 separate python lists that can store variable values depending on the time when script runs, for example:

```
requestId=[123, 456, 789, 987, 654, 321]
requestTitle=['Title1', 'Title1', 'Title2', 'Title3', 'Title3', 'Title3']
requestBodyText=['BodyText1', 'BodyText1', 'BodyText2', 'BodyText3', 'BodyText3', 'BodyText3']

```

I need to distinguish which requests are duplicated and which are unique based on `requestTitle` and `requestBodyText` (if request has identical requestTitle and requestBody then it is a duplicate), for the above it would be then:

```
uniqueList=[123,789,987]
duplicateList=[456, 654, 321]

```

once I know this then I need to pair requestIds in order to pass values to my `for loop` in `emails.py` as `x` (unique) and `y` (duplicate) variables. My goal here is to relate all the duplicate to unique requests via API. 

After pairing results should look as follows:

```
uniqueIds =[123, 987, 987]
duplicateIds=[456, 654, 321]

```

987 appears twice, because it has two duplicate emails 654 and 321. So it has to run two times to relate both requests (654 and 321) see below:

emails.py:

```
HOST = 'https://myUrl.com/path/'

def update_request(request, token, userid):
    headers = {     'accept': 'application/json',
                    'Content-Type': 'application/json',
                    'my-token': token,
                    'User-ID': userid}
    endpoint = 'request/'
    body = {'requestId': x, "addRelatedEmails": [{"id": duplicatedEmailId, "name": "EMAIL"}]}
    return requests.put(url = HOST + endpoint, headers = headers, json=body, verify=False)
    print(r.text)
    return True

for x, y in zip(uniqueIds, duplicateIds):
    update_requests(x, token, userid, duplicatedEmailId=y)

```

Not sure if the above is doable in a way I'm describing here, but maybe someone would be able to help with this or suggest easier solution? Thanks in advance. 

To @Cireo:

```
requestId=[123, 456, 789, 987, 654, 321]
requestTitle=['Title1', 'Title1', 'Title2', 'Title3', 'Title3', 'Title3']
requestBodyText=['BodyText1', 'BodyText1', 'BodyText2', 'BodyText3', 'BodyText3', 'BodyText3']

from collections import defaultdict
groups = defaultdict(list)  
for i, low, up in zip(requestId, requestTitle, requestBodyText): 
   groups[(low, up)].append(i)

```

When I call `groups` I'll get this (which seems like a half way to my goal):

```
groups
defaultdict(<class 'list'>, {('Title1', 'BodyText1'): [123, 456], ('Title2', 'BodyText2'): [789], ('Title3', 'BodyText3'): [987, 654, 321]})

```

but now I need to do the following:

```
uniqueIds = [123, 987, 987] #here I list IDs to my requests that are duplicated. What is important I need to store them as many times as they duplicate. So 123 has one duplicate, 987 has two duplicates therefore I listed this twice.

duplicateIds=[456, 654, 321] #here only the duplicates that I need to relate to my uniqueIds. 

```

So once I pass `uniqueIds` along with `duplicateIds` to my for loop it should relate:

Request 123 with Request 456

Request 987 with Request 654

Request 987 with Request 321

I'm ignoring request 789 as it has no duplicate.