s = 'one two one two one' print(s.replace(' ', '-')) # Output - # one-two-one-two-one s = 'one two one two one' print(s.replace(' ', '')) # Output - # onetwoonetwoone