python replace space with underscore in list code example Example: python replace space with underscore mystring.replace(" ", "_")