Wednesday, 29 December 2021

To count the number of vowels in a user entered string.


 Program/Source Code

Here is source code of the Python Program to remove the nth index character from a non-empty string. The program output is also shown below.

string=raw_input("Enter string:")
vowels=0
for i in string:
      if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
            vowels=vowels+1
print("Number of vowels are:")
print(vowels)



Runtime Test Cases
 
Case 1:
Enter string:Hello world
Number of vowels are:
3
 
Case 2:
Enter string:WELCOME
Number of vowels are:
3


No comments:

Post a Comment