[英]How to find a words - First letter will be capital & other will be lower
Filter those words from the complete set of text6, having first letter in upper case and all other letters in lower case.从完整的 text6 集中过滤这些单词,第一个字母大写,所有其他字母小写。 Store the result in variable title_words.
将结果存储在变量 title_words 中。 print the number of words present in title_words.
打印 title_words 中存在的单词数。
i'm facing the same problem as the below link,我面临与以下链接相同的问题,
How to find a word - First letter will be capital & other will be lower 如何找到一个单词 - 第一个字母大写,其他字母小写
no answers are accepted in the challenge.挑战中不接受任何答案。
neither 2341 or 461.既不是 2341 也不是 461。
Try this!尝试这个!
title_words = []
for item in set(text6):
if item.istitle():
title_words.append(item)
print(len(title_words))
Or more pythonic:或者更多的pythonic:
title_words = [x for x in set(text6) if x.istitle()]
print(len(title_words))
def check(word): if(word[0].isupper()==True and word[1:len(word)].islower()==True): return word else: return False print(check("App"))
def check(word): if(word[0].isupper()==True and word[1:len(word)].islower()==True): return word else: return False text6=set() text6.update(["word","App","Jsk"]) for i in text6: def check(word): if(word[0].isupper()==True and word[1:len(word)].islower()==True): return word else: return False text6=set() text6 .update(["word","App","Jsk"]) for i in text6:
print(check(i))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.