Generation

generate functionSun, 13 Nov 2022

from a set of elements, find out if any 4 of the elements are consecutive numbers

def consec(elems): for i in range(len(elems) - 3): if elems[i] + 1 == elems[i+1] and elems[i] + 2 == elems[i+2] and elems[i] + 3 == elems[i+3]: return True return False

Questions about programming?Chat with your personal AI assistant