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
Post a Comment