标签:most var size turn find put puts sdi class
Find the leftmost digit that occurs in a given string.
Example
inputString = "var_1__Int"
, the output should befirstDigit(inputString) = ‘1‘
;inputString = "q2q-q"
, the output should befirstDigit(inputString) = ‘2‘
;inputString = "0ss"
, the output should befirstDigit(inputString) = ‘0‘
.
我的解答:
def firstDigit(inputString): return [i for i in inputString if i.isdigit()][0]
def firstDigit(inputString): for i in inputString: if i.isdigit(): return i
标签:most var size turn find put puts sdi class
原文地址:https://www.cnblogs.com/YD2018/p/9490612.html