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

15th May 2020, 11:02 AM
MITESH VATS
MITESH VATS - avatar
1 Odpowiedź
+ 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)
15th May 2020, 11:14 AM
M Tamim
M Tamim - avatar