[Solved] Print the length of the longest continuous sequence (Python)
Try this instead: sequence = [] stop = False while not stop: num = int(input()) if num == -1: stop = True else: sequence.append(num) longest = 0 length = 0 for i in range(2, len(sequence)): if (sequence[i-2] + sequence[i-1]) == sequence[i]: length += 1 else: longest = max(longest, length) length = 0 First, I read … Read more