#open the file data = open("Problem_00008data.txt") digits = [] maxProduct = 0 #read in the first 5 characters for i in range(0,5): digits.append(data.read(1)) #loop until we reach the end of the file while True: product = 1 #For all the characters in our array #Find the product for digit in digits: product = product * int(digit) #If this is the maximum product, then #set the new value if product > maxProduct: maxProduct = product #remove the first digit #and append another digit to the list digits.pop(0) digit = data.read(1) if digit == "": break else: digits.append(digit) #close off the data file data.close() print "Maximum product is: %d" % (maxProduct,)