Count the vowels in a string

In this program, we will take a string as input and count the vowels in a string.

Steps to solve the program
  1. Take a string as input.
  2. Create a list containing all the vowels and create a count variable and assign its value equal to 0.
  3. Use for loop to iterate over each character from the string.
  4. If that character is present in the vowels add 1 to the count variable.
  5. Print the output.
				
					#Input string
string = "welcome to Sqatools"
vowels = ["A","E","I","O","U",
         "a","e","i","o","u"]
count = 0

for char in string:
    if char in vowels:
        count += 1

#Printing output
print(count)
				
			

Output :

				
					7
				
			

swap commas and dots in a string.

split a string on the last occurrence of the delimiter. 

Leave a Comment