Advertisement
gauravssnl

UniqueTupleInList.py

Mar 30th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. # UniqueTupleInList.py by gauravssnl
  2. # generates a list unique (a,b) pair for a range of number such that (b,a) does not appear in list & a != b
  3.  
  4. n = range(1,5)
  5. L = [ (x,y) for x in n for y in n if x!= y   ]
  6. S = [ ]
  7. for t in L :
  8.     if tuple( set(t)) not in t :
  9.         S.append(t)
  10.  
  11. print S
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement