Security and Cryptography in Python

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

相信未来 - 该面对的绝不逃避,该执著的永不怨悔,该舍弃的不再留念,该珍惜的好好把握。
原文地址:https://www.cnblogs.com/keepmoving1113/p/14359401.html