Anti_vowel solution question


#1

https://www.codecademy.com/courses/learn-python/lessons/practice-makes-perfect/exercises/antivowel

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:
      text.replace(letter,'')
  return text



#2

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


#3

Here:

text.replace(letter,'')

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,'')

#5

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


#6

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