def anti_vowel(text):
for c in text:
if c == "e":
c = "2"
return text
print anti_vowel("ee2ee")
Why does this print "ee2ee", not "22222"?
I said, whenever "e" comes out, replace it to "2".
I really can't understand.
def anti_vowel(text):
for c in text:
if c == "e":
c = "2"
return text
print anti_vowel("ee2ee")
Why does this print "ee2ee", not "22222"?
I said, whenever "e" comes out, replace it to "2".
I really can't understand.
You loop over text by making consecutive copies of characters into c.
You only ever change c.
c = "2"
There is nothing which changes text before you return it.