Problem picture

Keypad

Sample input output

`a` = `2`
`b` = `22`
`z` = `9999`

# type(ā€˜c’)
output => [222]

type('thanks')
# Output => [8, 44, 2, 66, 55, 7777]

Solution

def messageToList(msg):
    data = {
    'a' : 2,
    'b' : 22,
    'c' : 222,
    'd' : 3,
    'e' : 33,
    'f' : 333,
    'g' : 4,
    'h' : 44,
    'i' : 444,
    'j' : 5, 
    'k' : 55,
    'l' : 555,
    'm' : 6,
    'n' : 66,
    'o' : 666,
    'p' : 7,
    'q' : 77,
    'r' : 777,
    's' : 8,
    't' : 88,
    'u' : 888,
    'v' : 9,
    'w' : 99,
    'x' : 999,
    'y' : 9999,
    'z' : 99999
    }
    result = []
    for char in msg:
        if data.get(char):
            result.append(data[char])
    
    return result
            
    
print(messageToList('hi'))

Congratualtions. Problem is solved.

Happy coding :)