Three Words [isalpha() 字母]

思路:

# Three Words
# 
def checkio(words: str) -> bool:
    words=(words.split())
    count_1=0
    for x in words:
        if x.isalpha():
            count_1+=1
        else:
            count_1=0
        if count_1==3:
            return True
    return False


#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
    assert checkio("Hello World hello") == True, "Hello"
    assert checkio("He is 123 man") == False, "123 man"
    assert checkio("1 2 3 4") == False, "Digits"
    assert checkio("bla bla bla bla") == True, "Bla Bla"
    assert checkio("Hi") == False, "Hi"
    print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")

扩展:

str.isalnum()# 所有字符都是数字或者字母 
str.isalpha()# 所有字符都是字母 
str.isdigit()# 所有字符都是数字 
str.islower()# 所有字符都是小写 
str.isupper() #所有字符都是大写 
str.istitle() #所有单词都是首字母大写,像标题 
str.isspace()# 所有字符都是空白字符、\t、\n、\r
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值