Here you have:
word_input = list(word_input)
So word_input is a list of strings (in particular of characters). vowels is:
vowels = list('aeiou')
i.e. an other list of strings.
You do:
word_input.remove(vowels)
which always fails because vowels is a list of strings and word_input only contains strings. remove removes a single element. It does not remove all elements contained in the argument.
See the error message:
In [1]: vowels = list('aeiou')
In [2]: vowels.remove(vowels)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-6dd10b35de83> in <module>()
----> 1 vowels.remove(vowels)
ValueError: list.remove(x): x not in list
Note that it says: list.remove(x): x not in list so the argument to remove should be an element of the list, not a list of elements to remove.
You have to do:
for vowel in vowels:
word_input.remove(vowel)
to remove all vowels. Moreover remove only removes the first occurrence of the element, so you may have to repeatedly call remove to remove all occurrences of a vowel.
Note: to remove vowels from a string you could simply use:
the_string.translate(dict.fromkeys(map(ord, vowels)))
as in:
In [1]: the_string = 'Here is some text with vowels'
...: vowels = 'aeiou'
...:
In [2]: the_string.translate(dict.fromkeys(map(ord, vowels)))
Out[2]: 'Hr s sm txt wth vwls'
Or if you want to use those lists:
result = []
# vowels = set('aeiou') may be faster than using a list
for char in word_input:
if char not in vowels:
result.append(char)
word_input = list(word_input) vowels = list('aeiou') word_input.remove(vowels)this have no sense. what exactly you try to remove?