Security and Cryptography in Python - Implementing a counter on how many permutations there are

Security and Cryptography in Python - Implementing a counter on how many permutations there are

from itertools import permutations

my_list = [1, 2, 3]

list_of_permutations = permutations(my_list)
for permutation in list_of_permutations:
    print(permutation)

Running Result:

image-20210201221247020

from itertools import permutations

my_list = [1, 2, 3, 4, 5, 6, 7]

list_of_permutations = permutations(my_list)
cnt = 0
for permutation in list_of_permutations:
    cnt += 1
print(len(my_list), cnt)

Running Result:

image-20210201221552350

posted @ 2021-02-01 22:17  晨风_Eric  阅读(68)  评论(0)    收藏  举报