lst라는 리스트에서 'b' 요소의 모든 index 찾기
lst = [ 'a', 'b', 'c', 'b', 'c', 'd', 'e', 'b' ]
res = [ x for x, y in enumerate(lst) if y == 'b' ]
print(res)
---------------------------------------------------
[1, 3, 7]
'Python > Python Programming' 카테고리의 다른 글
[Python] Monodb Connection Using pymongo. (파이썬을 이용한 몽고DB 이용) (0) | 2019.11.06 |
---|---|
[Python] Integer maximum value. (정수 자료형 범위) (0) | 2019.11.01 |
[Python] reduce 함수 (0) | 2019.10.24 |
[Python] dateutil 모듈을 이용한 전년,전월,전일,D-day 날짜 구하기 (0) | 2019.10.21 |
[Python] Windows OS Disk Usage Check. (윈도우 운영체제 디스크 사용량 체크) (0) | 2019.10.18 |
[Python] Extract directory and filename. (디렉토리와 파일명 추출하기) (0) | 2019.10.18 |
[Python] Directory make and remove with subdirectories. (하위 디렉토리 포함 생성과 삭제) (0) | 2019.10.18 |
[Python] Directory make and remove. (디렉토리 생성과 삭제) (0) | 2019.10.18 |