Skip to content Skip to sidebar Skip to footer

Why Isn't The Replace() Function Working?

I'm scraping a website using Selenium. When I get the text of a list of elements (headers), this is what it prints: ['Countyarrow_upward Reportingarrow_upward Totalarrow_upwar

Solution 1:

strings are immutable. so header_raw_text.replace() does not change the string itself.you have to do reassign the result after replacing.

header_raw_text = header_raw_text.replace("arrow_upward ", "")

Post a Comment for "Why Isn't The Replace() Function Working?"