Computer Science, asked by tonydhaka123, 7 months ago

Write a python program to count and display the vowels of a given text​

Answers

Answered by Anonymous
8

Explanation:

Take a string from the user and store it in a variable. Initialize a count variable to 0. Use a for loop to traverse through the characters in the string. Use an if statement to check if the character is a vowel or not and increment the count variable if it is a vowel. Print the total number of vowels in the string.

Answered by Equestriadash
8

Source code:

n = input("Enter a string: ")

c = 0

print()

print("The vowels are: ")

for i in n:

 if i in "AEIOUaeiou":

   print(i)

   c = c + 1

print("And there are", c, "vowels.")

Once the string is entered, a loop starts, that traverses through the string. The string is given as the range, and the changing variable 'i' takes up all the values from the string. If it satisfies the if clause, the proceeding statements will occur.

Attachments:
Similar questions