Advertisement
here2share

# list_substring_divider.py

Sep 8th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. # list_substring_divider.py
  2.  
  3. words = ['one', 'two', 'abc','123', 'xyz']
  4. string = 'python thirty-two three phone# 12 $123.45 two a-b-c'.split()
  5.  
  6. zzz=[]
  7. found=[]
  8. nil='' # ? Maybe fixed in Python 3
  9. for s in string: (found if [nil for word in words if word in s] else zzz).append(s)
  10. print('Items Found In String: %s' % (found))
  11. print('Items Not Found In String: %s' % (zzz))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement