Write a Python program that accepts a sentence and find the number of words, digits, uppercase letters and lowercase letters
Program:-
sentence = input("Enter a sentence : ") wordList = sentence.split(" ") print("This sentence has", len(wordList), "words") digCnt = upCnt = loCnt = 0 for ch in sentence: if '0' <= ch <= '9': digCnt += 1 elif 'A' <= ch <= 'Z': upCnt += 1 elif 'a' <= ch <= 'z': loCnt += 1 print("This sentence has", digCnt, "digits", upCnt, "upper case letters", loCnt, "lower case letters")
Output:-
Enter a sentence : Rama went to Devaraja market to pick 2 kgs of vegetable
This sentence has 11 words
This sentence has 1 digits 2 upper case letters 42 lower case letters