python 删除列表空元素或相同元素

a=[‘a’,’b’,’c’,’a’,’d’,’a’]

如何把所有的’a’删除呢?

我的笨方法:
for i in a:
if i == ‘a':
a[a.index(i)] = ”

while ” in a:
a.remove(”)

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>