Anti_vowel solution question


I know you can just do something like this:

def anti_vowel(text):
  vowel = 'euioaEUIOA'
  rev =''
  for letter in text:
    if letter not in vowel:
      rev += letter
  return rev

I tried to do it differently and it does not do what I want it to do.

I expect it work and remove all vowels.

def anti_vowel(text):
  vowel = 'euioaEUIOA'
  for letter in text:
    if letter in vowel:
  return text


The letter “y” should not be included in your list of vowels, as it is only sometimes considered a vowel.




You have created a new string from text, but haven’t stored it anywhere. You have to store it, otherwise, your new string won’t get saved. If your new string isn’t saved, it can’t be returned. In order to remedy this, set the above line equal to a variable, like so:

text = text.replace(letter,'')


A post was split to a new topic: Python vs java


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