replace parts of string pyython no spaces code example Example: replacing spaces in a string python mystring.replace(" ", "_")