Python does not use the strip () method to remove spaces

Why did he return none?

Mar.20,2021

Recursively forgot to write and return. When judging s [0] = "" , you should reutrn ltrim (s)


.

it is more convenient to replace spaces directly with re.sub

import re  
  
text = "I am an handsome boy"  
print(re.sub(r'\s+', '', text))  
Menu