Anti_vowel


#1

My code is only returning the first letter of the phrase.

Your function fails on anti_vowel(“Hey look Words!”). It returns “H” when it should return “Hy lk Wrds!”.



def anti_vowel(text):
  result=''
  for n in text:
    if n not in "aeiouAEIOU":
      result+=n
    return result



#2

return result

return terminates a function whenever a return statement is reached it ends at that moment.

so return statement shouldn’t be inside for loop.


#3

thank for your solution. Here my code, I just made it more difficult than it should be =.=

def anti_vowel(text):
  a=["u","e","o","a","i","U","E","O","A","I"]
  temp=""
  for item in text:
    c=0
    for char in a:
      if item==char:
        c=1
    if c!=1:
      temp+=item    
  return temp

#4

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