I'm writing code to organize some textual data. In my code I need to check for a string and delete all list elements with that string in them. The following is part of my code:
for i in range(0, len(split_data)):
if 'Vienna' in split_data[i]: #list index out of range
del split_data[i]
I understand that the error (List index out of range) means that I am calling a value using an index out of range of the list. However, I'm a bit confused, since I have used len(split_data) which would obviously be the length of the list. I would appreciate if anyone could give me some guidance or suggestions. [I am a novice programmer]
Here is a subset of the data in split_data: split_data ~ ['538980', '33', "OFFICER'S CHOICE", '1402', 'BDA LIMITED', '12, EVERGREE INUDSTRIAL ESTATE, SHANKTI MILLS LANE, MAHALAXMI, MUMBAI - 400 011.', 'Opposed', ' ', 'APPLICATION DATE : 29/10/1990', 'USER DATE :', 'GOODS/SERVICES : ALCOHOLIC BEVERAGES INCLUDING WHISKY, BRANDY, GIN, RUM, VODKA AND WINE INCLUDED IN CLASS 33.']