Advertisement
here2share

# if_any_or_all_in_string.py

Oct 12th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. # if_any_or_all_in_string.py
  2.  
  3. elements = ['one', 'two', 'three']
  4. def oAny(z):
  5.     print z
  6.     print any(TrueFalse in z for TrueFalse in elements)
  7.     print
  8. oAny('abc 123 xyz')
  9. oAny('abc one 123 two xyz three')
  10. oAny('abc 123 two xyz')
  11.  
  12. def oAll(z):
  13.     print z
  14.     print all(TrueFalse in z for TrueFalse in elements)
  15.     print
  16. oAll('abc 123 xyz')
  17. oAll('abc one 123 two xyz three')
  18. oAll('abc 123 two xyz')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement