خرید بک لینک

Vote count: 0

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 retu or something?

counter = []

def reducing_white(txt):
    counter = txt.count(' ')
    while counter > 2: 
      txt = txt.replace(' ','',1)
      counter = txt.count(' ')
      retu txt

asked 1 min ago

1 Answer

Vote count: 0

This should work:

" ".join(txt.split())

answered 19 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 9 ارديبهشت 1395 ساعت: 9:51

صفحه بندی