I have a method
def strip_searchname(self, original_name):
taboo = {" and ", " of ", " at ", " in ", ":", "-", ",", " the ", " "}
searchname = original_name
for word in taboo:
print(searchname)
searchname = searchname.replace(word, "")
searchname = re.sub('[^a-zA-Z]', "", searchname)
searchname= searchname.upper()
return searchname
(yes, I know parts of it are redundant)
The first .replace seems to be stripping the entire string of whitespace, which I do NOT want. Why is this? How do I avoid it?
(e.g. output is:
Seattle University
SeattleUniversity
SeattleUniversity
SeattleUniversity
SeattleUniversity
SeattleUniversity
SeattleUniversity
SeattleUniversity
SeattleUniversity
SEATTLEUNIVERSITY
)
It’s not a list.
is a set literal. Try replacing { and } by [ and ] to get the order you want.