This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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