![](/img/trans.png)
[英]How to find a word - First letter will be capital & other will be lower
[英]How to find a words - First letter will be capital & other will be lower
從完整的 text6 集中過濾這些單詞,第一個字母大寫,所有其他字母小寫。 將結果存儲在變量 title_words 中。 打印 title_words 中存在的單詞數。
我面臨與以下鏈接相同的問題,
挑戰中不接受任何答案。
既不是 2341 也不是 461。
嘗試這個!
title_words = []
for item in set(text6):
if item.istitle():
title_words.append(item)
print(len(title_words))
或者更多的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:
print(check(i))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.