Python code for printing the string without vowels using list comprehension

0 votes
I have the python code for taking a string as the input and printing it after removing the vowels. How do I achieve the same using list comprehension? Thank you
Jul 8 in Python by Anvit
44 views

1 answer to this question.

0 votes

Hey @Anvit, you can use something like this:

def without_vowels(sentence):
    vowels = 'aeiou'
    print (''.join([ l for l in sentence if l not in vowels]))

if __name__ == '__main__':
    n = raw_input("Enter a sentance")
    without_vowels(n)
answered Jul 8 by Rajeev

Related Questions In Python

0 votes
1 answer

Normal Python code equivalent to given list comprehension

You can try this code list1=[] for i in ...READ MORE

answered Jun 8, 2018 in Python by jain12
• 160 points
33 views
0 votes
1 answer

What is the recommended way to randomize a list of strings using Python?

Hi. Nice question. Here is the simplified answer ...READ MORE

answered Jan 18 in Python by Nymeria
• 3,520 points
49 views
+4 votes
6 answers
0 votes
1 answer

Removing surrounding whitespace

Try the strip() function:  s = s.strip() If you ...READ MORE

answered May 4, 2018 in Python by Nietzsche's daemon
• 4,260 points
41 views
0 votes
1 answer