Anti-vowel


#1

Hi,

This is my code and it passed but I'm sure there's a better way to construct it. Any tips

def anti_vowel(text):
    words = list()
    for t in text:
        if t == 'A' or t == 'a' or t == 'E' or t=='e' or t=='I' or t=='i' or t=='O' or t=='o' or t=='U' or t=='u':
            continue
        else:
            words.append(t)
    word = ''.join(words)
    return word
    print word

anti_vowel('Hello')

#2

I definitely would check if its a vowel with:

if t .lower() in "aeiou":

#3

Nice result, but can not see a case statement. My solution used two loops ( extra one for checking vowels), yours is better.
It is nice to see somebody else who has stuck to the course material available to this point for a solution.


#4

Hi! In short, it my option. Not so big as your, but may be somebody can do more interesting.....

def anti_vowel(text):
    a=["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
    res=""
    for i in a:
        text=text.replace(i,"")
    return text

#5

I wouldn't check lower and upper case by adding them all to the tuple.

def anti_vowel(text):
vowel = ["A", "E", "I", "O", "U"]
for l in text:
if l.upper() in vowel:
text=text.replace(l,"")
return text
print anti_vowel("Hello")


#6

at the end i come with this, hope it helps!

def anti_vowel(text):
    novowel = ""
    for x in range(len(text)):
        if text[x] in "aeiouAEIOU":
            continue
        else:
            novowel += text[x]
    return novowel

#8

def anti_vowel(text):
    vowels = ("a","e","i","o","u","A","E","I","O","U")
    for y in vowels:
        text = text.replace(y,"")
    return text

#9

def anti_vowel(text):
for x in text:
if x.lower() in "aeiou":
text = text.replace(x, "")
return text`


#10

def anti_vowel(text):
for i in text:
if i in "aeiouAEIOU":
text=text.replace(i,"")
return text


#11

def anti_vowel(text):
string = ""
for char in text:
if char == char in 'aeiouAEIOU':
string += ""
else:
string += char
return string


Simple code


Also, how do people make the gray blocks with indentations and everything for their code when posting it, pls help.


#12

This is how you format code.


#13

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


#14

to make the grey block....you go to create new topic, while there everything is already done for you, ie there is a place you paste your link, a place for your codes, expectations, errors etc...then you just post ...