Python: Indexing locations of a sub within a string
<p>I am trying to create a program that will list the locations at which a sub-string occurs within a parent string. For example, say we search for "bc" within the parent string "abcabcabcabcabcabca" the program would return 1, 4, 7, 10, 13, 16.</p>

<p>So far I have been working with: </p>

<pre><code>import string

def subStringMatchExact():
    print "This program will index the locations a given sequence"
    print "occurs within a larger sequence"
    seq = raw_input("Please input a sequence to search within: ")
    sub = raw_input("Please input a sequence to search for: ")
    n = 0
    for i in seq:
        x = string.find(seq, sub [n:])
        print x
        n = x + 1
</code></pre>

<p>I have also tried replacing string.find with string.index operator. Any advice would be much appreciated.</p>
