开发者

python: whtat is the right way to remove element from list

google no found... I want two solutions:

1) How to remove an element in a for..in.. loop for a list?
2) How to remove all the elements in the list开发者_Go百科?


  1. This is almost never what you want to do. Use a list comprehension to filter out the items you don't want.

  2. del L[:]


1) filter()
2) list = []
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜