在Python中,有沒有一種方法可以檢查列表中的重複項目,如果有,然後刪除它們?我在尋找這樣的事情:提前Python - 查找並銷燬列表中的重複項目
>>> def check():
>>> # put code here
>>> list = ["foo", "foo", "bar"]
>>> check(list)
>>> list
["foo", "bar"]
>>> list2 = ["foo", "bar", "example"]
>>> check(list2)
>>> list2
["foo", "bar", "example"]
謝謝!
更新:
夥計們,我真的很新的編程和順序並不重要。所以for
循環應該沒問題。不過謝謝你!
TYSM!你是一個救星! – bladezzz 2012-03-31 17:53:41