def escape_html(s):
for (i, o) in (("&","&"),(">", ">"),("<", "<"),('"', """)):
s = s.replace(i , o)
return s
I haven’t seen something like this before.
What does the first line of the for loop mean?
In general, what does the loop do and how does it do it?
Note: s is a string
Please try to explain the full iterative process.
foreach pair of itemsiandointhe sequence of pairs(("&","&"),(">", ">"),("<", "<"),('"', """)), itreplaces each instance ofiwithoin the strings.