My problem sees me cycling through a long number in order to find the largest product of 5 consecutive digits within said number. I have a solution, but it currently involves the hard coding of the elements' positions, feels/looks hideous and is not scalable (what if I wanted the the sum of the 10 consecutive terms?). Is there a way to "Python" up this solution and nest it or optimise it in some way?
n = 82166370484403199890008895243450658541227588666881
N = str(n)
Pro = 0
for i in range(0, len(N) - 4):
TemPro= int(N[i])*int(N[i+1])*int(N[i+2])*int(N[i+3])*int(N[i+4])
if TemPro> Pro :
Pro = TemPro
print(Pro )
OS: Windows 7
Language: Python 3