Python/Python Basic
Python Basic : list.index (list 속 특정 값의 index 얻기)
CosmosProject
2021. 3. 30. 00:26
728x90
반응형
notes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
print(notes.index('A'))
print(notes.index('C'))
-- Result
9
0
list에 index(value)를 적용하면 value를 list내에서 찾아 그 value의 index를 반환해줍니다.
728x90
반응형