9
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pythonリストの複数要素削除

Last updated at Posted at 2017-08-12

いい関数ないんですかね。
使い方:dellist(リスト、削除したいインデックス)

dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
A=["a","b","c","d","e","f","g","h"]
r=[0,4,5]

dellist(A,r)
>>['b', 'c', 'd', 'g', 'h']
9
14
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?