How to check if a word is present in list

My output from script execution is

agent: {
“stdout_lines”: [ The network is reachable. …Connected using winrm, executin COMPLETED at 4/5, The file is saved at D:\ ]
}

I want to extract ‘COMPLETED’ from this list.

In python logic:

listToStr = ’ '.join([str(elem) for elem in agent[“stdout_lines”]])
iscomp=‘COMPLETED’ in listToStr

How to covert this into ansible.

agent.stdout_lines|select(‘search’, ‘COMPLETED’)|list !=

Hi Matt Martz

Excellent solution. For my windows role I have to change to

agent[“stdout_lines”]|select(‘search’,‘COMPLETED’)|list !=