python - Determine condition in list of strings -
i'm used c# , writing python script. want determine if of strings in list contain string "error".
in c# this:
string mymatch = "error"; list<string> mylist = new list<string>(); bool matches = mylist.any(x => x.contains(mymatch)); my attempt in python tells returns true though list contains strings contain word error.
def isgood (linesforitem): result = true; if 'error' in linesforitem: result = false return result
sounds mean:
def isgood(linesforitem): result = true if any('error' in line line in linesforitem): result = false return result or more simply:
def isgood(linesforitem): return not any('error' in line line in linesforitem)
Comments
Post a Comment