I am trying to group the indexes of the customers based on the following condition with python.
If database contains the same contact number or email, the result should return the indexes of the tuples grouped together in a sub-list.
For a given database:
data = [
("Customer1","contactA", "emailA"),
("CustomerX","contactA", "emailX"),
("CustomerZ","contactZ", "emailW"),
("CustomerY","contactY", "emailX"),
]
The above example shows that Customer1 and CustomerX shares the same contact number, and CustomerX and CustomerY shares the same email, hence Customer1, CustomerX and CustomerY are the same customer.
Hence the result is [[0, 1, 3], [2]]