#!/usr/bin/python3 from sys import exit larger = 0 current = -1 three = [] counter = 1 zahlen = [] with open('input.txt', 'r') as myfile: # create a list from all lines for lines in myfile: zahlen.append(int(lines.strip())) laenge = len(zahlen) for i in range(laenge): # stop it, if end of list is reached if i + 2 >= laenge: break csum = zahlen[i] + zahlen[i+1] + zahlen[i+2] print('{} :: {} + {} + {} = {}'.format(i, zahlen[i],zahlen[i+1],zahlen[i+2], csum)) three.append(csum) for item in three: if current > -1: if item > current: print ('current: {} < {}'.format(current, item)) larger = larger + 1 current = item print('{} measurements are larger than the previous measurement'.format(larger)) exit