fork download
  1. from difflib import SequenceMatcher
  2. string = '''Adam is a boy who lives in Michigan.
  3. He loves to eat apples and oranges.
  4. He also enjoys playing with his dog and cat.
  5. Adam is a happy boy.'''
  6. substring = "He loves to apple oranges"
  7. print('\n'.join(s for s in string.splitlines() if SequenceMatcher(' '.__eq__, s, substring).ratio() < 0.6))
Success #stdin #stdout 0s 23688KB
stdin
Standard input is empty
stdout
Adam is a boy who lives in Michigan.
He also enjoys playing with his dog and cat.
Adam is a happy boy.