string - Split when character changes in Python -
Then I have this string. / Code> so that I can replace 6 = M or 666 = O or 9 = W just like the phone's dial pad. 6 # 666 # 665533999 -> 6, 666, 66, 55, 33, 999 so I used to remove # split ('#') > And it does not understand what to do next. I have tried the methods of brute force which solves it to some extent, but is it easy or more elegant solution? Use: & gt; & Gt; & Gt; C = "6 # 666 # 665533999"> gt; & Gt; & Gt; ("6", '666', '66', '55', '33', '999 '] ["". Then there is a dictionary which MAP for a character in the dial pad. cmap = {'77': 'Q' '9999': 'z') #and further ...