I am trying to extract the index of an element in a list that says the word "FAILED".
In my application, I am looking to extract the specific element because I want to apply some regular expression to get some info regarding the FAILED status.
test_list = ["This is a test element", "This is a FAILED test element"]
if any("FAILED" for x in test_list):
failed = x
end_line = test_list.index(failed)
else:
end_line = test_list[-1]
print(end_line)
I want x to == test_list[1] or x == 1.. In my application, I won't know the index of where "FAILED" will occur.
This is the error: NameError: name 'x' is not defined
Aucun commentaire:
Enregistrer un commentaire