Advertisement
here2share

# next_combo.py

Apr 17th, 2021
1,755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. # next_combo.py
  2.  
  3. def next_combo(values):
  4.     j = [[]]
  5.     for value in values:
  6.         L = len(j)
  7.         j += [i + [value] for i in j]
  8.         for result in j[L:]:
  9.             yield result
  10.        
  11. values = [1,2,3,4,5,6]
  12.  
  13. combo = next_combo(values)
  14.  
  15. while 1:
  16.     try:
  17.         print next(combo)
  18.     except:
  19.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement