Assume you have a list
>>> m = [\'a\',\'b\',\'c\']
I\'d like to make a new list n that has everything except for a given
n
We can do it without using in built remove function and also without creating new list variable
Code:
# List m m = ['a', 'b', 'c'] # Updated list m, without creating new list variable m = [x for x in m if x != a] print(m)
output
>>> ['b', 'c']