Reverse


#1

def anti_vowel(text):
word = []
for i in text:
if i in ("aeiouAeiou"):
text.replace(i, "")
else:
word.append(i)
string = "".join(word)
print string
anti_vowel("Hey look Words")

It prints Hy lk Wrds. It says that it prints None :disappointed_relieved:. What s the matter?


#2

You should return string in anti_vovel(text) function.
Replace line print string with return string
Then under definition use print anti_vowel("Hey look Words")


#3

yup sorry and i wrote "aeiouAeiou" instead of "aeiouAEIOU" :joy:
Thank you anyways :slight_smile:


#4

Instead of an empty list, since you input will always be a string you should create an empty string like so,

word = " "

Then,

What you are trying to do here works but is less legible. How about using the not in keyword like,

for i in text:
   if i not in "aeiouAEIOU":
        #Then just add all the contents into your empty string
        word += i
        #After doing so for your anti_vowel text to show up when called return the now filled string
return word

After doing all that your code should work :grin:


#5

thank you :slight_smile:


#6

opps, .............................didnt mean to reply


#7

def reverse(text):
rev = ""
n = len(text) - 1
while n >= 0:
print text[n],
n -= 1

reverse("Python!")

But this gives this as reply - ! n o h t y P
how do i eliminate spaces between them so it gives result as !nohtyP

PS: The code is indented properly. I am not able to indent it here properly.


#9

Thanks i figured it out, Now i am stuck at Purify function.


#10

Still stuck? :slight_smile:


#11

No. I am almost done with the course. At 98%. Thanks though.