Anti_vowel


#1

I wrote this assuming python can iterate through two strings at a time

vowels = "aeiouAEIOU"

text = raw_input("?")

def anti_vowel(text):
    for (i,l) in (text,vowels):
        if text[i] == vowels[l]:
            text.replace(vowel,"")
        else:
            return text
    return text
print anti_vowel(text)

I got this error, what does it mean (the last sentence)?

? abcdef
Traceback (most recent call last):
  File "python", line 12, in <module>
  File "python", line 6, in anti_vowel
ValueError: too many values to unpack

#2

you can, but you need to use zip()


#3

vowel = "aeiouAEIOU"
string = []
def anti_vowel(text):
    text_out_vowel = ""
    i = 0
    for t in text:
        for c in vowel:
            if t == c:
                t = ""
        string.append(t)
        text_out_vowel += string[i]
        i += 1
    return text_out_vowel
print anti_vowel("How does it feel? To be on your own?")

printed :

Hw ds t fl? T b n yr wn?

but The site gives an error:

Oops, try again. Your function fails on anti_vowel("How does it feel? To be on your own?"). It returns "Hy lk Wrds!bcdHy lk Wrds!H" when it should return "Hw ds t fl? T b n yr wn?".



#4

the exercise calls the function multiply times with different strings to validate it works correctly, so everything you need for getting rid of vowels should be in function


#7

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