There's a lot out there on similar topics, but nothing I've found (on this website or elsewhere) seems to answer my question. That's because I want to do this with a for loop; not by importing modules like string
, or using regexes, etc.
I have a tuple consisting of some characters I don't like.
A string is then checked against this tuple, the idea being that if these forbidden characters are elements in the string, they'll be removed.
get_rid_of_us = ('.', '"', '?', ' ')
def fix_me(text):
text = ''.join(text.split()) # removing whitespace
text = text.lower() # making it lowercase
for i in get_rid_of_us:
if i in text:
text = text.replace(i, '')
return text
else:
return text
where text
is user input from elsewhere in the script, and goes on to be used afterwards. Something is wrong with my for
statement - what am I missing? Thanks :)