0

I created a function to remove items from a list. The items to be removed are passed in as a list in the function argument.

Here is the code:

a = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']

def drop_data(data):
for i in a:
    if i in data:
        a.remove(i)
return a

data_r = ['one', 'two', 'three']

drop_data(data_r)

output:

['two', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']

Why can't i remove 'two' from the list?

ilias-sp
  • 6,135
  • 4
  • 28
  • 41

0 Answers0