Advertisement
amaimon02

Combinação sem repetição

Aug 3rd, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. # Calcular combinações possívels sem repetição e tendo ordem como sem importância
  2. import itertools
  3.  
  4. my_list = ['A', 'B', 'C', 'D']
  5. all_combs = []
  6. for n in range(1, len(my_list)+1):
  7.     all_combs.extend(itertools.combinations(my_list, n))
  8.  
  9. for item in range(0, len(all_combs)):
  10.     print(all_combs[item])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement