1

I am trying to remove wowels in a random text.

def disemvowel(string):
    wowels = "aeiouAEIOU"
    wowellist = list(wowels)

    correctedList = list(string)

    for i in correctedList:
        for j in wowellist:
            if i == j:
                j = wowellist[0]
                correctedList.remove(i)
                print(i)


    string = "".join(str(x) for x in correctedList)
    return string

print(disemvowel("Your text wowel will be removed!"))

But when removed first wowel "o" second one "u" is not processed. I think it is due to correctedList.remove(i) but how can I remove an element in the list another way?

nuriselcuk
  • 515
  • 1
  • 4
  • 17

1 Answers1

2
def disemvowel(string):
    wowels = "aeiouAEIOU"
    wowellist = list(wowels)

    correctedList = list(string)
    outlist=[x for x in correctedList if x not in wowels]
    string = "".join(str(x) for x in outlist)
    return string

print(disemvowel("Your text wowel will be removed!"))
DZurico
  • 637
  • 4
  • 11