简体   繁体   中英

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. Store the result in variable title_words. print the number of words present in 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.

Try this!

title_words = []
for item in set(text6):
    if item.istitle():
        title_words.append(item)
print(len(title_words))

Or more 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

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM