I need to transform the string:
"There are 6 spaces in this string."
to:
"Thereare6spacesinthisstring."
You can use replace
string = "There are 6 spaces in this string"
string = string.replace(' ', '')
new = "There are 6 spaces in this old_string.".replace(' ', '')
If you want to strip all whitespace, including tabs:
new = ''.join( old_string.split() )