Skip to content

Instantly share code, notes, and snippets.

@altendky
Created October 27, 2016 14:36
Show Gist options
  • Save altendky/208785bf1e6d2833c6ae49444cd4f51a to your computer and use it in GitHub Desktop.
Save altendky/208785bf1e6d2833c6ae49444cd4f51a to your computer and use it in GitHub Desktop.
list1 = ['1\n', '00:04:11,588 --> 00:04:13,920\n', 'Nurse Evelyn! Nurse Evelyn!\n', '\n', '2\n', '00:04:15,024 --> 00:04:17,788\n', 'I have a message for you. In English!\n', '\n', '3\n', '00:04:35,345 --> 00:04:37,575\n']
def get_strings_position_in_list(astring, alist, position):
for position, string in enumerate(alist):
if alist[position].find(astring) != -1:
yield position
for g in get_strings_position_in_list(" --> ", list1, 0):
print(g)
### next(g) output 1, and then next(g) it still be 1, It should be 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment