Issue
['16:False,', '15:False,', '17:True,']
I need to know the index of str with true value
It is at index 2 but how do i make code like this for that
Solution
Not sure if this is what you're asking for, but this will return the index of all items in the list with "True" in them:
my_list = ['16:False,', '15:False,', '17:True,']
indexes = [idx for idx, s in enumerate(my_list) if "True" in s]
print(indexes)
>>> [2]
Answered By - Kike Laguilhoat
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.