Remove consonants from a string (GFG)

 Remove consonants from a string 

Given a string s, remove all consonants and prints the string s that contains vowels only.
Input: The first line of input contains integer T denoting the number of test cases. For each test case, we input a string.
Output: For each test case, we get a string containing only vowelsIf the string doesn't contain any vowels, then print "No Vowel"

Constraints:

1<=T<=100

The string should consist of only alphabets.

Examples:

Input: geEks
Output: eE
Input: what are you doing
Output: a ae ou oi


SOLUTION:

t= int(input())
for i in range (t):
    s=input()
    ans = ''
    for l in s:
        if l in "aeiouAEIOU ":
            ans += l
    if ans == '':
        print("No Vowel")
    else:
        print(ans)

Comments

Popular posts from this blog

Short Notes Of computer Network

Short Note of Data Structure

Sort in specific order (GFG)