In every iteration of the loop, text is "Hello World", and the last vowel of text is "o", so at the end of the loop, no_vowel is "Hell Wrld".
In python2.7, use method translate instead. Here is the official document:
translate(...)
S.translate(table [,deletechars]) -> string
Return a copy of the string S, where all characters occurring
in the optional argument deletechars are removed, and the
remaining characters have been mapped through the given
translation table, which must be a string of length 256 or None.
If the table argument is None, no translation is applied and
the operation simply removes the characters in deletechars.
"Hello World".translate(None, "aeiouAEIOU") gives the correct result "Hll Wrld"
Also, re.sub('[aeiouAEIOU]', "", "Hello World") works for both python2.7 and python3
no_voweldefined?