Strip does not remove whitespace everywhere, only at the beginning and end. Try this:
def solve_eq(string1):
return string1.replace(' ','')
Using strip()
in this case is redundant (obviously, thanks commentators!).
P.s. Bonus helpful snippet before I take my SO break (thanks OP!):
import re
a_string = re.sub(' +', ' ', a_string).strip()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…