8. anti_vowel. Syntax error: "Can't assign to function call." Help


Here’s my code:

I don’t understand the error?

def anti_vowel(text):
  vowels = "a", "e", "i", "o", 'u'
  for w in text:
    if i in vowels == w in text:
      text() -= vowels(i)
    return text

print anti_vowel("Hey you!")



text() -= vowels(i)

text() is a function call, not sure why you made a function call. Its what the error refers to, but i easily see more mistakes


I tried “text(i) -= vowels(i)” It may be my understanding of function calls that’s messing me up. I see this code as taking the “i” in text and subtracting it by the “i” in vowels


anti_vowel is a function:

def anti_vowel(text):

the def keyword indicates the definition of a function, then anti_vowel is the name of the function, then between the parentheses you define the parameter(s) then you call the function here:

print anti_vowel("Hey you!")

but text is a string. So doing:


will attempt to call a string, but strings are not callable. Functions are, strings are not


vowels = "a", "e", "i", "o", 'u'

this should be a list, how do we make a list? Feel free to check earlier lessons or documentation if need a syntax refresher.

could you explain me how this comparison:

if i in vowels == w in text:

is suppose to work?


I thought that it would take the i in vowels, the (a, e, i, o, u), and the w in text (“H” “e” “y” “y” “o” “u” “!”) and subtract any that would be equal in I.D. Which I believed to be the vowels


Sorry if I’m saying anything wrong here, but I’m truly trying my hardest.


no, the in keyword check if something is present within a string or list, for example:

print "a" in "abc"

will print True. So we can use this, we can check if w is in vowels.


So it checks if something is present. So I can use that to check it but I still don’t understand where to go from here.


first you need to fix vowels variable, you need to make it a list.

we could construct a new string when w is not in vowels, just like with reverse a few exercises back


This is my new code. Still won’t work?

def anti_vowel(text):
  vowels = ["a", "e", "i", "o", 'u']
  anti_v = ""
  for i in text:
    if i not in vowels:
      anti_v += i
  return anti_v

print anti_vowel("Hey you!")


what about uppercase vowels? A, E, I and so on?


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