Which of the following is the best method to find the indices of all occurances of a word in a string?
line = 'mary had a little lamb, little lamb, little lamb'
word = 'lamb'
Correct Answer: import re indices = [occurance.start() for occurance in re.finditer(word, line)]
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More Python MCQ Questions