How can I have the indices of the string 'OFF' from the given list. I tried to loop through the list with an if statement but I was unsuccessful
New_Layer_list =[[6], [1], [1, 3, 'OFF', 7, ':OFF', 8, 9], [1, 3, 7, ':OFF', 8, 9, 0, 6]]
OFF_index_list = []
for i in New_Layer_list:
for j in i:
if j == 'OFF':
OFF_index_list.append(i.index(j))
else:
pass
print(OFF_index_list)
I don't understand why it only gives me index 2 and not 4 and 3 along with
Aucun commentaire:
Enregistrer un commentaire