Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python

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.

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

Name: Anonymous 2013-03-13 7:04

or (the best way ^^) is to invert the loop =D and only iterate over the length of the search word =) zfilter style

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List