f = open("file", "r") str = f.read() f.close() lst = [] for paquet in str.split("\n\n"): Sum = 0; for sub_paquet in paquet.split("\n"): if (sub_paquet != ""): Sum += int(sub_paquet) lst.append(Sum); print(max(lst))