8. anti_vowel my code works but how did i commit this vow=vow crime


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096#.

My code behaves fine except that it is INCORRECTLY coded by me because,
i couldnt figure out how to handle the index flow in a conditional way.
Hence i came up with my own stitch work to it and it OUT-RIGHT FUNNY, very childish.
look at the line 6 in my following code
<

Please tech me how to not deal with such foolish mindset and assert my logic properly....because i feel i beat the lowest layman level with this. I tried to replace on line 6 with following

x=x+1
---(on line:6)

to move index to skip a vowel print.
But it turns out that str and int wont gel up due to the obvious >racism< between them


text = "pratik"
def anti_vowel(text):
    vow = ""
    for x in text:
        if x in "aeiouAEIOU":
            vow = vow  
        else:
            vow += x
    return vow
print anti_vowel(text)

I want to remove vow=vow logic production behaviour of my brain too


#2

then you should find the solution here:

if x in "aeiouAEIOU":

we want to add x to vow if x is not present in vowel string, which keyword did we learn we can use to reverse a condition?


#3

yes i tried the keyword

not in

that but then what do i write in else????
how to progress the index liek we used to do in other languages by writing i++ as a counter


#4

@stetim94
yes i tried the keyword

not in

that but then what do i write in else????
how to progress the index liek we used to do in other languages by writing i++ as a counter


#5

you don't write anything in else, that is the trick

then we can add x to vow in if clause, and then else clause does nothing, so we can remove it


#6

oh ok in that case, one last question,
Is it not a bad habbit to leave the else clause empty or not have an else clause
i am asking this because i have seen in the past that many people suggesting that having no else clause is dangerous or is an incomplete logic, or is a wrong coding style because other varied inputs may cause unrequired, incorrect, or erroneous output and may mess up with output functionality by causing unusual exceptions

IS above true?? thats it, that is last matter i want to clarify
gratitude for your response and happy with it


#7

says who? I would like to see sources for that. I will disagree with it, if you only need to do something for a specific case, only having an if is perfectly fine


#8

ok, perfect, absolutely fine then.
I had that kind of comments from editors and solvers in STACKOVERFLOW, where, they werent happy with only if and no else...

well thats ok, as long as this way of coding is fine, i am happy to be enlightened
this increases my much needed confidence

Thanks, this solves my query in a more complete manner


#9

for certain scenarios this might certainly be true, not here.


#10