How do I reduce whitespace in Python from
test = ' Good '
to single whitespace test = ' Good '
I have tried define this function but when I try to test = reducing_white(test)
it doesn't work at all, does it have to do with the function return or something?
counter = []
def reducing_white(txt):
counter = txt.count(' ')
while counter > 2:
txt = txt.replace(' ','',1)
counter = txt.count(' ')
return txt