Anti_vowel (returns only 1st letter)


#1

This function returns only first letter and i can't understand why
could you help please?

def anti_vowel(text):
    for i in text:
        if i in "aeiouAEIOU":
            i = ""
            
        return ''.join(i)

`


#2

A function ends the moment a return keyword is reached

If a return keyword is reached in a loop, the loop simply breaks


#3

Oh the same mistake again, thank you i'll try


#4

def anti_vowel(text):
    for i in text:
        if i in "aeiouAEIOU":
            i = ""
            
    return ''.join(i)

now it returns only ! form Hey look Words


#5

i is your iterator, changes made to it won't persist.

Make a list/string (you choice which is best) before the loop, add constants to this string/list, and return the reversed string after the loop has finished running


#6

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