convert string to a list python and remove spaces code example Example: replacing spaces in a string python mystring.replace(" ", "_")