Replace all spaces with underscore Python code example Example: python replace space with underscore mystring.replace(" ", "_")