How to Display the statistics in the given string using Python

STATISTICS



CODING OF THE PROGRAM

msg=input("Enter a string ")
v,c,u,l,s=0,0,0,0,0
for ch in msg:
       if ch.isupper( ):
              u=u+1
       if ch.islower( ):
              l=l+1
       if ch in"AEIOUaeiou":
              v=v+1
       if ch.isspace( ):
              s=s+1
       if ch.isalpha and ch not in "AEIOUaeiou":
              c=c+1
print('''Given string "%s" contains %d vowels %d consonants %d uppercase characters %d lowercase characters %d space'''%(msg,v,c,u,l,s))

OUTPUT OF THE PROGRAM

Enter a string God is Great
Given string "God is Great" contains 4 vowels 8 consonants 2 uppercase characters 8 lowercase characters 2 space
 










Comments

Popular posts from this blog

Program to find out whether a given number is prime number or not in python[using break statement]

How to display Floyd's triangle in python program

How to display BMI(Body mass index )using python program