Advertisement
here2share

# any_in_array.py -- no ORs'ing around! (inside humor)

May 29th, 2015
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. # any_in_array.py - no ORs'ing around! (inside humor)
  2.  
  3. # Note: tuples and lists are read as sets. Also, instead of 'in' it's '&'
  4. a = (1,2,3,4,5,'target',6,7,8,9,10)
  5. b = [100,200,'target',300,400,500]
  6. c = [100,200,300,400,500]
  7.  
  8. def areAnyInList(first_array,second_array):
  9.     print "In",first_array,'\nand',second_array
  10.     if set(first_array) & set(second_array):
  11.         print 'an identical item value has been found'
  12.     else:
  13.         print 'none are identical'
  14.     print '\n'*4
  15. #
  16.  
  17. areAnyInList(a,b)
  18. areAnyInList(a,c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement