program to Get max. consecutive sum of 2 numbers in a list?
from random import randint
elem = randint(2, 20)
L = list()
for _ in range(elem):
L.append(randint(1,9))
print(L)
max = 0
for i in range(len(L) - 1):
if L[i] + L[i + 1] > max:
max = L[i] + L[i + 1]
print(max)
Comments
Leave a comment