作业帮 > 综合 > 作业

求助python题目This function receives a string st containign lett

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/09/22 23:24:12
求助python题目
This function receives a string st containign letters or digits and an integer number pos. The function should return the number of letters that there are in the input string st, starting to count from position pos (counting the character in pos if it is a letter) and advancing one position at a time visiting the string until encountering a digit or until reaching the end of the string. If pos is not a valid position in the string, the function should return 0.

For example:

countLettersFromPosUntilDigit('12abc456',0) should return 0

countLettersFromPosUntilDigit('abc456',1) should return 2

countLettersFromPosUntilDigit('123abc',3) should return 3

countLettersFromPosUntilDigit('abc123de',0) should return 3

An example:
countLettersFromPosUntilDigit('12abc456', 0) should return 0
求助python题目This function receives a string st containign lett
这种题目自己写一下吧,不难的。
countLettersFromPosUntilDigit(st,pos)开始,从st[pos-1]开始一个个往后数,看有连续几个字母就行了。