Anti_vowel


#1




Code says that it needs a str not an int

Traceback (most recent call last):
File "python", line 8, in
File "python", line 5, in anti_vowel
TypeError: 'in ' requires string as left operand, not int


Tried to search in a list of characters for each letter in the word and if its not included in that string of characters (vowels) then it would print to the screen.


def anti_vowel(text):
    text = str(text)
    vowels ='aAeEiIoOuU'
    for l in range(0, len(text) - 1):
        if l not in vowels:
            print l
            
anti_vowel(raw_input('word'))


#2

And.. do you agree with that it should be a string, and not an int?

Is it a string or an int?


#3

Yes, I think it should be a string, that's why I put in str(text), I just don't understand why it's not


#4

If it is a number, will converting it to string give you the value you want? Sounds more like you should be using some other value, not trying to convert something that doesn't have the information you mean to use.

If it's the wrong value, then think about where you were supposed to get the value you wanted from, where does that information exist?

You should probably also consider what the range function does, both because it's very useful and because it's probably not at all what you want to be using here, and by learning what it does you'd know why you don't want to use it. (Also you should only use things that you know what they do - anything new means you gotta read up on it first)


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.