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
- Take a string as input.
- Create an empty string and a list containing all the vowels.
- Using for loop check whether a character from the input string is a vowel or consonant.
- If it is a vowel then add it to the empty list 3 times each.
- If it is a consonant add it to the empty list 2 times each.
- 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