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, 2019 in Python by Anvit

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")
answered Jul 8, 2019 by Rajeev

Related Questions In Python

+1 vote
1 answer
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
• 170 points
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, 2019 in Python by Nymeria
• 3,540 points
+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
0 votes
1 answer

How can I write code to find a palindrome in python without using string functions?

In Logic 1, try if i<int(length/2): instead of if i<int((length/2+1)): In ...READ MORE

answered Jan 16, 2019 in Python by charlie_brown
• 7,750 points
0 votes
1 answer