I am working with list data and want to filter out my data, basically, I want to remove all the recurring elements from a list:
list = ['0260','1234','02/03/2020','1245','1.1','','','112233','abcd','','','',
'0260','1235','02/03/2021','1215','1.2','','','112233','abcd','','','',
'0260','1224','02/03/2023','1225','3.1','','','112233','abcd','','','',
'0260','1114','02/03/2024','1235','6.1','','','112233','abcd','','','',
'0260','1224','02/03/2025','1265','17.1','','','112233','abcd','','','',
'0260','1564','02/03/2026','1275','19.1','','','112233','abcd','','','',
'0260','1904','02/03/2027','1295','11.1','','','112233','abcd','','','',
]
desired result = ['0260','1234','02/03/2020','1245','1.1',
'0260','1235','02/03/2021','1215','1.2',
'0260','1224','02/03/2023','1225','3.1',
'0260','1114','02/03/2024','1235','6.1',
'0260','1224','02/03/2025','1265','17.1',
'0260','1564','02/03/2026','1275','19.1',
'0260','1904','02/03/2027','1295','11.1',
]
I tried multiple approaches but none of them seems to be working. I tried list comprehension and a while loop:
while 2 in x:
x.remove(2)
However it only removes one element at a time, but I want to go through all the list elements, check and then delete multiple elements accordingly.