remove whitespace from string python and replace with underscore code example Example: python replace space with underscore mystring.replace(" ", "_")