Greetings Python List, <div><br></div><div>I have a motif sequence (a list of characters e.g. &#39;EAWLGHEYLHAMKGLLC&#39;) whose index I would like to return. </div><div>The list contains 20 strings, each of which is close to 1000 characters long making it far too cumbersome to display an example. </div>
<div>I would like to know if there is a way to return a pair of indices, one index where my sequence begins (at &#39;E&#39; in the above case) and </div><div>one index where my sequence ends (at &#39;C&#39; in the above case). In short, if &#39;EAWLGHEYLHAMKGLLC&#39; spans 17 characters is it possible</div>
<div>to get something like 100 117, assuming it begins at 100th position and goes up until 117th character of my string. My loop goes as </div><div>follows: </div><div><br></div><div>for item in finalmotifs:</div><div>    for line in my_list:</div>
<div>        if item in line:</div><div>            print line.index(item)</div><div><br></div><div>But this only returns a single number (e.g 119), which is the index at which my sequence begins. </div><div><br></div><div>
Is it possible to get a pair of indices that indicate beginning and end of substring?     </div><div><br></div><div>Many thanks</div><meta charset="utf-8"><div><div><br></div><div><br></div></div>