I am trying to implement a function which replaces the following values:
# > with >
# < with <
# " with "
# & with &
I keep getting an error with my function. What exactly is wrong?
def escape_html(s):
data = list(s)
if ">" in data:
data.replace(">",">")
if "<" in data:
data.replace("<","<")
if '"' in data:
data.replace('"',""")
if "&" in data:
data.replace("&","&")
word = data.join()
return word
print escape_html("<>")
Note: This is more of a fundamental programming question. My focus is the reason why my function isn't working. I cannot use outside libraries for this project.