- 1
Not getting the desired output whats the mistake?
Program to print word without vowels:- Code:- word = input() x=[i for i in word if(i!='a','e','i','o','u')] print(x) Above is the code I wrote but not getting desired output need help.
12 Réponses
+ 2
Hi ANIKET!
I suggest you to use and operator instead.
Because, or operator evaluates true(means 1), if any condition is satisfied.
For example,
if i != a is a true statement then your entire condition will be true even if i is equal to e or other vowels.
When you're trying to connect many conditions using logical operators, you have to compare all characters(here vowels) separately.
Here it is your working code.
word = input()
x=[i for i in word if i!='a' and i != 'e' and i != 'i' and i != 'o' and i != 'u']
print(x)
+ 1
Thanks for the help
+ 1
✩✮★✮✩ I think it may more better answer if you will explain your code.
I think you are trying to make a program which collect consonants of a word or sentence.
word = input().lower()
#Data given by user is stored in variable word ,in lower case
x = [i for i in words if i not in "aeiou"]
#it will iterate through all letter of word append in list if letter is not available in string a, e, i, o or u
print("".join(x))
#x is list, if you want to make it display as string then use .join() it will join the list and make it str
[ Code by star star .... star ]
https://code.sololearn.com/cVX9E3fG3RoC/?ref=app
ANYKET:) See it!
+ 1
Thanks for the help Rishav Tiwari 🔥🔥
+ 1
ANYKET:) for that just print x, insted of using join() simple! ;)
All The Best! 👍
+ 1
Thankyou guys :)
0
Oops it's not working either
0
And what is I need those words in list ?
0
Do I have to split in such case?
0
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']
See this is the exact question
0
Thanks for sharing, very helpful
https://patronsurveys.com/