fox fox - 10 days ago 4x
Python Question

python: a quick way to return list without a specific element

If I have a list of card suits in arbitrary order like so:

suits = ["h", "c", "d", "s"]

and I want to return a list without the

noclubs = ["h", "d", "s"]

is there a simple way to do this?

>>> suits = ["h","c", "d", "s"]
>>> noclubs = list(suits)
>>> noclubs.remove("c")
>>> noclubs
['h', 'd', 's']

If you don't need a seperate noclubs

>>> suits = ["h","c", "d", "s"]
>>> suits.remove("c")