简体   繁体   English

如何查找单词 - 第一个字母大写,其他字母小写

[英]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"))

for update we can use input but in online compiler it throws eof erorr对于更新,我们可以使用输入,但在在线编译器中它会抛出 eof 错误

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.

相关问题 如何找到一个单词 - 第一个字母大写,其他字母小写 - How to find a word - First letter will be capital & other will be lower 如何使用正则表达式从 NLTK 语料库中查找大写字母单词? - How to find a capital letter words from an NLTK corpus using regex? 如何找到以大写字母开头的字符串中的单词? - how can i find the words in a string that start with capital letter? 正则表达式将单词与首字母大写匹配 - Regex to match words with first capital letter 查找以大写字母作为起始字母但前面没有空格的单词 - find words with capital letter as starting letter but not preceded by space Python:在大写字母前查找小写/数字的正则表达式条件 - Python: regex condition to find lower case/digit before capital letter 在2个大写字母(regex)之前找到以大写字母开头的n个单词 - Find n words starting with capital letter before 2 words of capital letters (regex) Python:如何在句子的单词列表中找到一个字母并以原始大小写返回这些单词(大写/小写) - Python: How to find a letter in a sentence's list of words and return those words in their original case (upper/lower) 如何在包含相同首字母python的列表中查找单词 - How to find words in a list that contain the same first letter python Python:字符串索引超出范围,试图找到第一个大写字母 - Python :string index out of range with trying to find first capital letter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM