Ahmed
Ahmed

Reputation: 129

i'am trying to make a function that deletes vowels in a string

def disemvowel(word):
    new_word = []
    list_of_letter = list(word)

    for letter in list_of_letter:       
        if letter == 'a' or 'A' or 'E' or 'e' or 'O' or 'o' or 'U' or 'u':
           continue
        else:
            new_word.append(letter)

    return ''.join(new_word)

Upvotes: 2

Views: 43

Answers (1)

iElden
iElden

Reputation: 1280

Your condition is always True
You should change it to:

if letter in "aAeEiIoOuU":

When you write

if letter == 'a' or 'A'

You said "if letter is 'a' or if 'A' is not a empty string", and a is not a empty string.

Upvotes: 2

Related Questions