I have a nested list of elements:
employee_list = [
['Name', '=', 'John'],
['Age', '=', '32'],
['Weight', '=', '60'],
['Name', '=', 'Steve'],
['Weight', '=', '85']
]
I want to create two lists of elements: one which has repeated elements and another with unique elements. But I also wanted the repetition to be maintained
unique_list = [['Age', '=', '32']]
repeated_list = [
['Name', '=', 'John'],
['Weight', '=', '60'],
['Name', '=', 'Steve'],
['Weight', '=', '85']
]
Uniqueness or repetition is determined by the first element of every sub list. For example: 'Name'
, 'Weight'
. If there are two sub lists where the first element is 'Name'
I consider it as repetition.
Can anyone suggest an easy way to do this?