Set-up
I have a pandas DataFrame df.
For each row in df['district'] I create a temp string which I append to list sl1.
Subsequently, I add two strings to each temp in sl1 and append the result to a second list sl2.
I do this in the following way,
sl1 = []
for key, value in df['district'].iteritems():
temp = "http://www.jaap.nl/huurhuizen/zuid+holland/agglomeratie+'s-gravenhage/'s-gravenhage"
sl1.append(temp)
sl2 = []
for link in sl1:
x = '<a href="' + link + '">'
sl2.append(x)
Issue
In the second for loop, something strange occurs. In stead of obtaining an sl2 filled with rows containing,
'<a href="http://www.jaap.nl/huurhuizen/zuid+holland/agglomeratie+'s-gravenhage/'s-gravenhage">'
the rows are filled with,
'<a href="http://www.jaap.nl/huurhuizen/zuid+holland/agglomeratie+\'s-gravenhage/\'s-gravenhage">'
How come Python adds those backslashes, and more importantly:
How can I prevent/remove them?
Does it have to do with the ' in 's-gravenhage?