Substitute multiple whitespace with single whitespace in Python [duplicate]

I have this string:

mystring = 'Here is  some   text   I      wrote   '

How can I substitute the double, triple (…) whitespace chracters with a single space, so that I get:

mystring = 'Here is some text I wrote'

3 Answers
3

Leave a Comment