/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
nDigitNumberCombinations.py
18 строк
457 B
slowy07
fixing module, code, and code cleanup (reformatted)
24 июл 2021, 17:50
24 июл 2021, 17:50
f3470d4
Код
Авторство
О чём код?
# ALL the combinations of n digit combo def nDigitCombinations(n): try: npow = 10 ** n numbers = [] for code in range(npow): code = str(code).zfill(n) numbers.append(code) except Exception: # handle all other exceptions pass return numbers # An alternate solution: # from itertools import product # from string import digits # list("".join(x) for x in product(digits, repeat=n))