itertools - Permutations in alphabetical order -


I want to get a list of every schedule from AAAA to ZZZZ, and I want to make the list alphabetically I am how can I do this?

You can solve it like this:

  alphabet = [Xrange (commodity ('A'), Ord ('Z') + 1) [CRR (Item)) for the item creates alphabet from capital A to capital Z.  
  perms = itertools.product (alphabet, repeat = 4)  

creates a generator that will convert all 4-character permutations to 'AAAA ' to ' ZZZZ '

  result = sorted (for code in' '. Code>  

Sort the results (note that product returns a 4-character alphabet, so we need to combine it with the described code as join .


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -