0

I am trying to make a function to delete all the unwanted space before the very first word in a string:

def spacefirst(sentence):
   for t in range(len(sentence)):
      if t == 0 and sentence[t] == ' ':
          sentence = sentence[t+1 :]
      else:
          sentence = ''.join(sentence) 
          return sentence
      spacefirst(sentence)

Why that recursion is not working?

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
SOUVIK DATTA
  • 13
  • 1
  • 5

0 Answers0