Computer Science, asked by abhishek330negi2000, 1 year ago

a program to accept a string and count no. of vowels ,consonent and spaces in the string and also find out the no. of words in it

Answers

Answered by estherroyin
2
this is the program to input a string and display the total number of vowels present in it.
Attachments:

abhishek330negi2000: thnkss a lot once again...i will pay my dept one day... be active for my more problems
estherroyin: haha sureexpecting soon
estherroyin: and dont forget to mark my both answers as brainlist .hehe
abhishek330negi2000: ya how can i forget it...,
abhishek330negi2000: by the way can you teach me nested loops
estherroyin: yeah post it as a question i ll give the syntax with example prgrm
estherroyin: a nested if is an if that has another if in its true part or in its false part
estherroyin: example program; write a program to input any three numbers and display the highest one
abhishek330negi2000: oky ...
abhishek330negi2000: heyy sry for late reply but this code is only for the vowels what about the other??????
Answered by Equestriadash
3

string = input("Enter a string: ")

cv = 0

for i in string:

 if i in "AEIOUaeiou":

   cv = cv + 1

cc = 0

for i in string:

 if i not in "AEIOUaeiou":

   cc = cc + 1

cs = 0

for i in string:

 if i == " ":

   cs = cs + 1

cw = 0  

for i in string.split():

 cw = cw + 1

print("Vowels: ", cv)

print("Consonants: ", cc)

print("Spaces: ", cs)

print("Words: ", cw)

Attachments:
Similar questions