I can't understand why this code is not giving me the intended results i.e replacing special characters like > with their special sequence like >
def escape_html(s):
for (i,o) in ((">",">"),
('<','<'),
('"','"'),
('&','&')):
s.replace(i,o)
return s
print escape_html('>')
print escape_html('<')
print escape_html('"')
print escape_html("&")
print escape_html("test&test")
Specially because I am literally copy pasting this code from this Udacity lesson
The code is giving this output
>
<
"
&
test&test
instead of replacing these special characters with their escape sequences.
I am aware of the fact that Python has in built support for escape_html function, but I want to understand what am I doing wrong?