Check if a string contains a number

后端 未结 16 1522
無奈伤痛
無奈伤痛 2020-11-22 11:14

Most of the questions I\'ve found are biased on the fact they\'re looking for letters in their numbers, whereas I\'m looking for numbers in what I\'d like to be a numberless

16条回答
  •  深忆病人
    2020-11-22 11:55

    Simpler way to solve is as

    s = '1dfss3sw235fsf7s'
    count = 0
    temp = list(s)
    for item in temp:
        if(item.isdigit()):
            count = count + 1
        else:
            pass
    print count
    

提交回复
热议问题