Repeat vowels and consonants 3 and 2 times resp.

In this program, we will take a string as input and repeat vowels and consonants 3 and 2 times respectively.

Steps to solve the program
  1. Take a string as input.
  2. Create an empty string and a list containing all the vowels.
  3. Using for loop check whether a character from the input string is a vowel or consonant.
  4. If it is a vowel then add it to the empty list 3 times each.
  5. If it is a consonant add it to the empty list 2 times each.
  6. Print the output
				
					#Input string
str1  = "Sqa Tools Learning"
result = ""
vowels = ["a","e","i","o","u",
          "A","E","I","O","U"]

for char in str1:
    if char in vowels:
        result = result + char*3
    else:
        result = result + char*2

#Printing output
print(result)
				
			

Output :

				
					SSqqaaa  TToooooollss  LLeeeaaarrnniiinngg
				
			

count vowels from each word in the given string show as dictionary

re-arrange the string.

Leave a Comment