/ Published in: Python
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 def normalize_whitespace(str): import re str = str.strip() str = re.sub(r'\s+', ' ', str) return str
Comments
                    Subscribe to comments
                
                