Question: If there's a window list

```
text='abcdefg'
window_list=[text[i:i+3] for i in range(len(text)-3)]
print window_list
['abc', 'bcd', 'cde', 'def']

for i in window_list:
    for j,k in zip(range(len(text)),i):
    print j,k
0 a
1 b
2 c
0 b
1 c
2 d
0 c
1 d
2 e
0 d
1 e
2 f

```

i'm trying to make it so when 

```
(j==0 and k=='c') and (j==1 and k=='d') and (j==2 and k=='e')

```

it would give me the starts and ending position where that occurs on the string text

so it would give me

```
[2-4]

```

Answer: 
Have you thought to do it in this way?

```
>>> text='abcdefg'
>>> window_list=[text[i:i+3] for i in range(len(text)-3)]
>>> ["-".join([str(i),str(i+len(w))]) for i,w in enumerate(window_list) if w == 'cde'] #for single item
['2-5']
>>> ["-".join([str(i),str(i+len(w))]) for i,w in enumerate(window_list) if w in ['cde','def']] # for multiple items
['2-5', '3-6']
>>> 

```

Note: [enumerate](http://docs.python.org/library/functions.html#enumerate)  the list and search for those items which matches the condition. Return the index followed by the end position (which is index + length of the sub-sequence). Please note, the result would be a string rather than what you are expecting.
**Logic:**

All you need to do is find if your pattern is in the doc or not. This can be done easily using Python in built string "find" function. Once you find the start position of your string, then all you need to do is add the length of your pattern to get end position. thats it! job done ;)

**The Code:**

```
text = "abcdefghifjklmnopqrstuvwxyz"
start_position = text.find("abc")
if(start_position>-1):
    end_position = start_position+len(start_position) - 1
else:
    print "Pattern not found"
print start_position, "-", end_position

```

**The Output:**

```
0 - 2

```

**Reference:**
Check Official Python String Functions Documentation