telephone number word generator python

88

numbs = {'2':'ABC', '3':'DEF', '4':'GHI', '5':'JKL', '6':'MNO', '7':'PQRS', '8':'TUV', '9':'WXYZ'}

def combo(phnum):
    if len(phnum) == 1: return list(numbs[phnum[0]])
    else: result = combo(phnum[:-1])
    return [(ch1+ch2) for ch1 in result for ch2 in numbs[phnum[-1]]]

Comments

Submit
0 Comments