For this regular expression code, I tried to find the co-occurrence of two keywords, "refuse" or "decline" with "visit" or "service":
row = " the patient declined to attend the visit"
match1 = re.findall("(?=.*(refus\w*|declin\w*))(?=.*(servic\w*|visit\w*))", str(row)) # write it as social security
print (match1)
When I print match1, it is the output:
[('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit'), ('declined', 'visit')]
But I want to print only one output: ('declined', 'visit')
would you please let me know what part of my code is wrong?