0

I am trying to remove vowels via user input. I have tried all sorts of things and looked up other question here as well and its just not working.

def d_vowel(word):
    word = input('give me a word: ')
    vowels = ['a', 'e', 'i', 'o', 'u']
    new_word = []
    for letter in word[:]:
        if not letter.lower() in vowels:
            new_word.append(letter)

    print(''.join(new_word))

d_vowel()
Keyur Potdar
  • 7,158
  • 6
  • 25
  • 40
Josh Bennett
  • 39
  • 1
  • 10
  • Welcome to stackoverflow. It seems like you have forgotten to ask a question in your question. Please read the sections [ask] and [MCVE]. – timgeb Mar 24 '18 at 13:34
  • 1
    What's the problem? This is very vague. – Carcigenicate Mar 24 '18 at 13:34
  • What's wrong? It's working perfectly after removing the `argument from function.` – the.salman.a Mar 24 '18 at 13:36
  • @Carcigenicate what do you mean its working perfectly? I get the prompt, I enter a word (per the prompt) and it prints the word unchanged. If I type 'hello', I get 'hello'. But I want 'hll'. – Josh Bennett Mar 24 '18 at 13:48
  • Here's your code after removing the argument `word` from the `d_vowel()` function- The Code: `def d_vowel(): word = input('give me a word: ') vowels = ['a', 'e', 'i', 'o', 'u'] new_word = [] for letter in word[:]: if not letter.lower() in vowels: new_word.append(letter) print(''.join(new_word)) d_vowel()` **Input** `give me a word: Hello world` **Output** ` Hll wrld` – the.salman.a Mar 24 '18 at 13:52
  • 2
    @JoshBennett You tagged the wrong person, but I checked it as well, and it works fine. "hello" yields "hll" as expected. The only change I made was to get rid of the call to `input` since it isn't needed, but that shouldn't effect anything. – Carcigenicate Mar 24 '18 at 13:52
  • I am running it in terminal and I keep getting the same result. WTF! – Josh Bennett Mar 24 '18 at 13:57
  • @JoshBennett That would only be possible if the letters being entered were weird variations of normal letters, or old versions of the code were being run. Restart your environment, because you can tell just looking over the code that it's not a problem with the code itself. – Carcigenicate Mar 24 '18 at 14:04
  • The only weird things with your code here at the fact that you have `word` as a paremeter, but then just overwrite it with the return from `input`, and the fact that you're copying `word` using `[:]` before iterating, which isn't necessary. Neither of those things will cause the behavior you're mentioning though. – Carcigenicate Mar 24 '18 at 14:06
  • I figured it out. Also removed the [:]. good point. – Josh Bennett Mar 24 '18 at 14:12
  • the input statement was just for giggles – Josh Bennett Mar 24 '18 at 14:12

0 Answers0