I have a list which looks like this:
my_list =
[['UK', 'Manchester City', 'Blue', '1','2','B'],
['ES', 'FC Barcelona', 'Blue', '2','1','C'],
['IT', 'Juventus', 'White', '3','2','A'],
['DE', 'Borussia Dortmund', 'Yellow', '4','1','A']]
Now I want to edit my_list
and actually delete the values in index0
,3
,4
and 5
.
This is my expected output:
my_list =
[['Manchester City', 'Blue'],
['FC Barcelona', 'Blue'],
['Juventus', 'White'],
['Borussia Dortmund', 'Yellow']]
This is the code I tried:
for list in my_list:
for idx in [0,3,4,5]:
del list[idx]
print(my_list)
This is the output I get:
IndexError: list assignment index out of range