I have strings which could have single, double or triple white spaces which I want to replace with a comma ','
I have used .replace(' ', ',') like so
white_space ="this has white spaces" #this has white spaces
white_space_replaced = white_space.replace(' ', ',') #this,has,white,spaces
double_white_space ="this has double white spaces" #this has double white spaces
double_white_space_replaced = double_white_space.replace(' ', ',') #this,,has,,double,,white,,spaces
But I want to only replace the white spaces with a single comma. How can I cater for multiple sizes of whitespaces in python3?