Skip to content

Instantly share code, notes, and snippets.

@computer-tutor
Created April 28, 2020 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save computer-tutor/e434127790a053682e769624946883a9 to your computer and use it in GitHub Desktop.
Save computer-tutor/e434127790a053682e769624946883a9 to your computer and use it in GitHub Desktop.
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