Answer to Question #241879 in Python for balu

Question #241879
Remove Vowels in a Sentence

You are given a sentence. Write a program to remove all the vowels in the given sentence. 

Note: Sentence has both lowercase and uppercase letters.

Input

The first line of input is a string 

N.

Explanation

In the example given a sentence 

Hello World, the sentence contains vowels e, o.

So, the output should be 

Hll Wrld.

Sample Input 1
Hello World
Sample Output 1
Hll Wrld
Sample Input 2
Once upon a time
Sample Output 2
nc pn  tm
Python 3.9
RESET
SAVE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
string = input()
if string == 'x':
    exit();
else:
    newstr = string;
   
    vowels = ('a', 'e', 'i', 'o', 'u');
    for x in string.lower():
        if x in vowels:
            newstr = newstr.replace(x,"");
    
    print(newstr);
     
     
         
                
        
Custom Input
RUN CODE
SUBMIT
TEST CASE 1
TEST CASE 2
Input
1
Once upon a time
Diff
Your Output
Onc pn  tm

Expected
nc pn  tm




1
Expert's answer
2021-09-24T14:24:52-0400
str_inp = input()
str_out = ''.join(i for i in str_inp if i.lower() not in 'aeoiu')
print(str_out)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS