Remove duplicate consecutive spaces from a given string, in-place. For example: "Have a nice day" should become "Have a nice day". Removal of leading and trailing spaces was not specifically mentioned.
Anónimo
foo - Using a recursive function foo2 - Using an iterative process def foo(s): if len(s) = 2: if s[i] == s[i+1] == " ": s = s[:i] + s[i+1:] else: i += 1 return s