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
0 answers
0 votes
1 answer

Write code to create a list of word lengths for the words in original_str using the accumulation pattern and assign the answer to a variable num_words_list.

Hi,  num_words_list = len(original_str.split()) original_str.split() - split words in ...READ MORE

answered May 27 in Python by Niroj
• 57,260 points
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
+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,780 points
–1 vote
1 answer