+ 1
Intermediate python 7.2 - Ignore the vowels - Practice help
How do you solve this? Given a word as input, output a list, containing only the letters of the word that are not vowels. The vowels are a, e, i, o, u. Sample Input awesome Sample Output ['w', 's', 'm'] word = input()
17 ответов
+ 7
Try this
word = "hello"
vowels = "aeiou"
result = []
for letter in word:
if letter not in vowels:
result.append(letter)
print(result)
+ 2
Here are two one-liner solutions:
#1
print([x for x in input() if x.lower() not in "aeiou"])
#2
print(list(filter(lambda x: x not in "AEIOUaeiou", input())))
# Hope this helps
+ 2
Try this innovative solution 😀
---------------------------
word=input()
y=set(word)
z=y-{'a','e','i','o','u'}
print(list(z))
---------------------------
used the concept of sets then again transformed into list. Have fun
+ 1
There are a number of ways to do this.
Can you attach your attempt so we may guide you to a solution
0
Take empty list.
By loop, extract each letter from input string, and if not vowel add to list. else don't .
Finally print list.
I solve this way.
How do you going to code ...? What do you tried so for..? Try and post your attempt, if unsolved..
0
0
'''
This is really basic stuff, which indicates you should review the sections you have completed.
Example code attached'''
word = "awsome"
vowels = "aeiou"
for letter in word:
if letter not in vowels:
print(letter)
0
Appreciate the help, but not so simple as thah doesnt work…. @rRik Wittkopp For Hello, that gives an output of:
h,
l,
l
And needs to be
[‘h’ , ‘l’, ‘l’]
Code:
word = input()
vowels = ('a','e','o','i','u')
#doesnt work with vowels = “aeiou” either
for letter in word:
if letter not in vowels:
print(letter)
0
Thanks - this worked:
word = input()
vowels = ('a','e','o','i','u')
result = []
for letter in word:
if letter not in vowels:
result.append(letter)
print(result)
0
word = input()
vowels = ['a', 'e', 'i', 'o', 'u']
letters = [i for i in word if i not in str(vowels)]
print(letters)
0
word = input()
print(list(i for i in word if i not in "aeiou"))
0
word = input()
not_vowels = [i for i in word if i not in ['a', 'e', 'i', 'o', 'u']]
print(not_vowels)
0
vow = ['a', 'e', 'i', 'o', 'u']
word = input()
list = [i for i in word if i not in vow]
print(list)
0
word = input()
vowels = ['a', 'e', 'i', 'o', 'u']
result = [letter for letter in word if letter not in vowels]
print(result)
0
word = input()
vowels = ('a','e','i','o','u')
not_vowels = [i for i in word if i not in vowels]
print(not_vowels)
- 1
Yes, there is a lot of way, how to solve it. One way is list comprehension. Try it.