def strip_formatted_string(str):
 return re.sub('\\s\\s+', ' ', str).strip()

def strip_formatted_string ( str ) : return re . sub ( '\\s\\s+' , ' ' , str ) . strip ( )
remove multiple whitespaces and whitespaces at the beginning and end of the given string .