如果我有任意顺序的卡片套装列表,如下所示:
suits = ["h", "c", "d", "s"]
我想返回一个没有
'c'
的列表noclubs = ["h", "d", "s"]
有没有简单的方法可以做到这一点?
最佳答案
>>> suits = ["h","c", "d", "s"]
>>> noclubs = list(suits)
>>> noclubs.remove("c")
>>> noclubs
['h', 'd', 's']
如果您不需要单独的noclubs
>>> suits = ["h","c", "d", "s"]
>>> suits.remove("c")