First digit after letter X48755


Statement
 

pdf   zip

Write a function @digit_after_let(s)@ that given a string ss returns a boolean and a character. The boolean is True when ss has some digit after some letter, otherwise is False. The character has to be the first digit in ss that comes out after some letter in the first case and the symbol ’$’ in the second one. You can use the string method @isalpha()@ to check whether given a string it has at least one character and all its characters are letters. For instance, @my_string.isalpha()@ is True when @my_string@ is ’HeLLo’ or ’X’ and is False when @my_string@ is ’He7TO’ or ’?;x’ or ’123456’.

Sample session

Sample session
>>> digit_after_let('123 456')
(False, '$')
>>> digit_after_let('Wrong Answer: -10- has to be -25-')
(True, '1')
>>> digit_after_let('451sTa')
(False, '$')
>>> digit_after_let('X@#2$Z5Y')
(True, '2')
Information
Author
ProAl
Language
English
Official solutions
Python
User solutions
Python