Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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), '%')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment