How to get the matched string
Question: I am using any() in python

    
    
    from inActivePhrase import phrase
    
    detailslist=[]
    
    for detail in detailslist:
        inactive = any(term in detail for term in phrase)
    

Where the phrase will have the list of strings like below

    
    
    phrase = ["not active","Closed",etc..]
    

The function is working fine. But i want to get the phrase which is present in
the detail.

**Example :**

    
    
      detail = "this is not active"
      inactive = any(term in detail for term in phrase)
       if inactive:
            print('matched phrase' + term) //how can i do this
    

in which the "not active" is the matched phrase. So i want to print it.

How can i do that. Can anyone help me ?

Thanks,


Answer: you could have several term matching detail

    
    
    detail = "this is not active"
    inactive = [term for term in phrase if term in detail]
    if inactive:
        print('matched phrases' + inactive) 
    

