Help me, give hints, not full answers please. | Sololearn: Learn to code for FREE!

+2

Help me, give hints, not full answers please.

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'] Use a list comprehension to create the required list of letters and output it.

11/30/2021 11:59:57 AM

Quarkom

12 Answers

New Answer

+4

1. Take the input string 2. Make a variable for vowels 3. Make a list comprehension of the input when it is not a vowel 4. Print the list

+7

One way to approach this could be: * split input word to a list of characters * create an empty list for the output * iterate over the input list: check for each character, if it is a vowel, if yes, then append it to the output list * print output list after the loop

+6

Quarkom , you are just trying to solve the task from the tutorial "intermediate python". this tutorial requires some basic knowledge of "python for beginners" or "python core". to solve the task you need to know how toe use loops (for loop), lists and list comprehensions. if you are not familiar with this items, you should go an other learning path to get the basics, and then later come back to solve the exercise. happy coding and good success!

+6

Lisa , just to mention, that we don't need to spilt the input to individual characters, since we can iterate directly on a string.

+5

list comprehension looks something like this a = [i for i in range (b)] 2. You need a if statement to check if the value is there or not using the in keyword and not.

+3

w= input() vowel = ['a','e','i','o','u'] x=[i for i in w if i not in vowel] print(x)

+2

Lothar Yes, you're right! I'm not sure if the question had been edited since I wrote my comment or if I missed something – but when I answered it, I read it as a beginner's question and wanted my approach to be very explicit about the steps.

+1

Thank you I solved it

+1

Lothar Ye, I did python for begginers but not python core, I will move to python core then to understand things better

+1

Quarkom Yeah, that's it, you can also use one string for the vowels instead "aeiou". #oneliner print([x for x in input() if x not in "aeiou"])

+1

Mafdi oh nice

0

I have no idea how to solve this one...