how to replace spaces with underscores in python code example Example: python replace space with underscore mystring.replace(" ", "_")