I have this code:
def remove_punctuation(self,text):
exclude = set(string.punctuation)
a=''.join(ch for ch in text if ch not in exclude)
return ''.join(c for c in a if not ud.category(c).startswith('P'))
First I would like to know what this does :
ch for ch in text if ch not in exclude
How is it possible to write a for loop like that?
second, I want to replace those punctuation let's say in a text like this : "hello_there?my_friend!" with a space using the above code. How can I change that code to do that?