['hoge','fuga','hogehoge','123456789','fugafuga']
から
[False, False, False, True, False]
と判定結果をつくってから、 index だけをとりだすようにしてみました。
num.py
python3
1results = [x.isnumeric() for x in a]
2print(results)
3ids = [i for i, e in enumerate(results) if e]
4print(ids)
5
6m = map(lambda i_el: i_el[0] if i_el[1].isnumeric() else None, enumerate(a))
7ids = [x for x in m if x]
8print(ids)
9
2つの方法を書いています。
最初の方法は [False, False, False, True, False] をつくって処理しています。
次の方法は、 map をつかって[None, None, None, 3, None] となるような itelater をつくって処理しています。

2018/09/06 08:10