Reputation: 627
How to get index of certain value in frozenset?
A= frozenset(['sungai','gunung'])
I want to get index of 'sungai'
?
Upvotes: 2
Views: 3452
Reputation: 627
Actually, I just have known, frozenset didn't have index. But i need it in my code. I create a naive function:
def cariIndex(setList, data2):
i=-1
for data in setList:
i=i+1
if data==data2:
return i
return -1
>> cariIndex(A, 'sungai')
0
Upvotes: 1