Name: Anonymous 2013-03-13 2:15
Is there any decent way to do this without the use of iteration?
It basically asks for 2 strings, and it'll search the word you input from the second string in the first while accounting for overlapping substrings.
It basically asks for 2 strings, and it'll search the word you input from the second string in the first while accounting for overlapping substrings.
def find_email():
email_message = raw_input("Enter the email message: ")
find_word = raw_input("Enter the word to find: ")
occurrence_count = 0
print range(len(email_message) - len(find_word) + 1)
for x in range(len(email_message) - len(find_word) + 1):
if email_message[x:x + len(find_word)] == find_word:
print email_message[x:x + len(find_word)]
print x
occurrence_count += 1
print occurrence_count