- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPhoneNumToLetter.py
More file actions
Latest commit
30 lines (27 loc) · 578 Bytes
/
Copy pathPhoneNumToLetter.py
File metadata and controls
30 lines (27 loc) · 578 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'''
Given a digit string,
return all possible letter combinations that the number could represent.
A mapping of digit to letters
(just like on the telephone buttons) is given below.
1 2abc 3def
4ghi 5jkl 6mno
7pqrs 8tuv 9wxyz
* 0 #
Input:Digit string "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
'''
phone_map= {
2:'abc',
3:'def',
4:'ghi',
5:'jkl',
6:'mno',
7:'pqrs',
8:'tuv',
9:'wxyz'
}
defletter_combination(str1):
letters= []
forcharinstr1:
ifphone_map[char]:
letters.append(list(phone_map[char])