I need to do a function that receives a string consisting of numbers between 2-9 and the output is letters, ie basically the function will work as a keyboard of a mobile phone, where the number '2' will match with 'A', '22' will match 'B', until '9999' matches with 'Z'. For example:
>>> def teclas('22 2 333 33')
"CAFE"
The values entered in the arguments can "loop around" in the sense that if you enter '2222', the letter will return 'A', '22222' the letter will be 'B', etc. Just like it works on a phone with keys. Right now I have a dictionary where I assign all numbers to the corresponding letters like this:
dic={'2':'A', '22':'B', '222':'C', '3':'D'....}
My question is how do I, if I enter '2222' as an argument, reassign it to 'A' (I do not know how to do the 'turn around' program).