f = open("file", "r") Calories = f.read() f.close() somme = [] sum = 0 l_calories = Calories.split("\n\n") for i in l_calories: liste = i.split("\n") for j in liste: sum += int(j) somme.append(sum) sum = 0 def sauver_noel(liste): for i in range(1, len(liste)-1): if liste[i-1] >= liste[i]: maxi = liste[i-1] else: maxi = liste[i] return maxi print(sauver_noel(somme))