Q:

Find if there are three consecutive indices in a list that ARE NOT equal to zero in python

I am python beginner, so I thought I could solicit some help here. 
Here are two input lists with only 0 and 1 for the sake of simplicity:
 x = [1, 1, 1, 0, 1]
 y = [1, 1, 0, 1, 0]

I am trying to define a logic in python that returns True for x because
it HAS three consecutive elements that ARE NOT EQUAL to zero; indices 0:2 are all not equal to zero. 
The same function would return nothing for y because y DOES NOT have three consecutive elements that ARE NOT EQUAL to zero.  I also mean consecutive in regards to the indices, not in regards to the values! 
In addition to solving this logic, the function should also return the index and the value of the last non-zero element of a patch of 3 non-zero elements in case the original condition is true.  
so, let's say I have a hypothetical function called is_three_consecutive_non_zero, here is what the function would return in either case:
is_three_consecutive_non_zero(x) # should evaluates to (True, 2, 1)

2 is the index of the last 1 in group of three consecutive ones and 1 is the value of the last non-zero element of the patch of non-zero three elements! 
If the first output is false, the function doesn't return anything else. 
Here is an annoying trio nested for-loop function with several if conditions that can be a good starting point:
def is_three_consecutive_non_zero(list):
if 0 not in list:
    return True, len(list)-1, list[len(list)-1]

for l in range(0, len(list)):
    for m in range(1, len(list)):
        for n in range(2, len(list)):
            if (l ! = m) & (m ! = l) & (n == m + 1) & (m == l + 1):
                if (list[l] ! = 0) & (list[m] ! = 0) & (list[n] ! = 0):
                    return True, n, list[n]

Let's try it:
is_three_consecutive_non_zero(x)
is_three_consecutive_non_zero(y)

It would be great if you could share any better logic or may be a single or two liner that utilize any other available python modules. 
By the way, these list are very small, so, I am not concerned about time or space issues.  I also only care about the FIRST PATCH of three non-zero elements:
z = [0, 1, 1, 1, 1]
is_three_consecutive_non_zero(z) # evaluates to (True, 3, 1) which is consistent with what I want

Thanks a lot

A:

Is this what you're looking for? 
def f(l):
    for i in range(len(l)-3):
        if all(l[i:i+3]):
            return True, i, l[i+2]
    return False, None, None

If you just want to get back whether or not three such values are in the list a one liner is any(all(l[i:i+3]) for i in range(len(l)-3))

