0
How can I count number of words in a sentence and total number of alphabets in the sentence?
Language: Python All symbols and numbers should be ignored. For example: "I don't like java, html...!!" Here number of words = 5 ...... and number of alphabets = 17
1 Answer
+ 1
a = "Hello, Mitesh"
number of words â
a = a.split()
print(len(a))
or,
print(count(" ") + 1)
number of alphabets.
There are literally a lot of ways. I show you one,
b = "ABC....XYZabc...xyz"
sum = 0
for i in a:
if in b:
sum += 1
print(sum)