Created
February 22, 2021 07:36
-
-
Save manmohan24nov/b2c173136f9d9d76b4fc23b562f8dfa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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