* Number of words
* Number of characters (including white-space and punctuation)
* Percentage of characters that are alpha numeric
Hints
* Assume any consecutive sequence of non-blank characters is a word.
# Code
s = input(‘Enter a sentence : ‘)
number_of_words = 1
number_of_characters = len(s)
al_num = 0
for i in s:
if i.isalnum():
al_num += 1
if i == ‘ ‘: # there is a space means there is another word
number_of_words += 1
print(‘number of words are’, number_of_words)
print(‘number_of_characters are’, number_of_characters)
print(‘percentage of characters that are alphanumric is’, al_num*100/len(s), ‘%’)