If I have a list like this:
MyList = [1,2,3,4,5,'hi', 6,7, 'hi', 8, 'hi', 9]
how can I remove all the items 'hi' from the list? I have tried the method remove() but it works only once:
MyList.remove('hi')
>>>> MyList
[1,2,3,4,5,6,7,'hi',8,'hi',9]
Yes, I could do something like this:
while 'hi' in MyList:
MyList.remove('hi')
but does anyone know any more elegant way than iterating n-times the same instruction?