0

How to get index a bool type value in a list

How is the best way for to get index in python list when the value is boolean. Example: list = ["test", 6, "Guitar", True, 97, False]

9th Oct 2020, 5:25 AM
Dario Silva
Dario Silva - avatar
2 odpowiedzi
9th Oct 2020, 5:50 AM
Oma Falk
Oma Falk - avatar
+ 1
list = ["test", 6, "Guitar", True, 97, False] index = [list.index(x) for x in list if type(x)==bool] print(index)
9th Oct 2020, 5:40 AM
Ruba Kh
Ruba Kh - avatar