def myTrim(s): if len(s) <= 0 or s[0] != ' ' and s[-1] != ' ': return s; if s[0] == ' ': s = s[1:] if len(s) > 0 and s[-1] == ' ': s = s[:-1] return myTrim(s); print(myTrim(' abasdfaf123123 '))
I just have to saying THIS IS A BEST INSTANCE OF RECURSION brother
厉害!!
Sign in to make a reply
靠墙小青年