I'm trying to delete leading comas in a sentence and I can't get why does this doesn't work
text = ",greetings friends"
text_l = text.split()
for word in text_l:
if word.startswith(','):
word = word[1:]
text = ' '.join(text_l)
>>> ,greetings friends
but this does.
text = ",greetings friends"
text_l = text.split()
for word in text_l:
if word.startswith(','):
indw = text_l.index(word)
text_l[indw] = word[1:]
text = ' '.join(text_l)
>>> greetings friends