Skip to content

Instantly share code, notes, and snippets.

@manmohan24nov
Created February 22, 2021 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manmohan24nov/b2c173136f9d9d76b4fc23b562f8dfa4 to your computer and use it in GitHub Desktop.
Save manmohan24nov/b2c173136f9d9d76b4fc23b562f8dfa4 to your computer and use it in GitHub Desktop.
>>> text_data_test = "Life is what life happens when you're busy life making other life plans."
>>> index_list = []
>>> flag = 0
>>> count = 0
>>> word_length = len('life')
>>> while 'life' in text_data_test:
... return_index = text_data_test.lower().find('life')
... print(return_index)
... if return_index == -1:
... break
... if len(index_list) == 0:
... index_list.append(return_index)
... else:
... index_list.append(return_index + word_length * count)
... text_data_test = text_data_test.lower().replace('life',"",1)
... print(text_data_test)
... count += 1
...
0
is what life happens when you're busy life making other life plans.
9
is what happens when you're busy life making other life plans.
35
is what happens when you're busy making other life plans.
49
is what happens when you're busy making other plans.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment