8.anti_vowel


#1



loop break at first. so result is just "H". I don't know why it not work. I think have problem with range. right?


just result is "H"


def anti_vowel(text):
    str(text)
    i=0
    newtext=""
    
    for i in range(len(text)-1):
        a = text[i]
        
        if a not in "a"or"e"or"i"or"o"or"u"or"A"or"E"or"I"or"O"or"U":
            newtext=newtext+a
            
        else :
            newtext=newtext
            
        return newtext
anti_vowel ("Hey look Words!")


#2

Don't do that. Just remove it. It has no effect.

The order that is evaluated is:

(a not in "a")or"e"or"i"or"o"or"u"or"A"or"E"or"I"or"O"or"U"

There is nothing there that says to compare the variable a to any of the strings there except "a". That whole condition is equivalent to just True, regardless of what your variable refers to.

If you think there is a problem with the range, (and there is) then print it out to inspect it.

Don't give control back to the caller until you have finished the job


#3

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