Код: Выделить всё
d = {
'1': "abc",
'2': "def",
'3': "ghi",
'4': "jkl",
'5': "mnop",
'6': "qrst",
'7': "uv",
'8': "wxyz",
'9': ".;",
'0': "?!"
}
Код: Выделить всё
def keypad_combination(d , s , result , indx):
if indx == len(s):
return result
if len(result) == 0:
result = result.extend(d[s[indx]])
else:
for char in result:
char += d[s[indx]]
return keypad_combination(d,s,result, indx+1)
result = []
print(keypad_combination(d,"573",result,0))
Код: Выделить всё
% python ./questions.py
['m', 'n', 'o', 'p']
Подробнее здесь: https://stackoverflow.com/questions/798 ... ect-result
Мобильная версия