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