きったんの頭

#! /usr/bin/env python3
"""
pe8.py
https://mind.kittttttan.info/py/pe8

pe8.txt
https://mind.kittttttan.info/c/pe8.txt
"""

def pe8(fname="pe8.txt", n=5):
    """
    Discover the largest product of five consecutive digits
    in the 1000-digit number.
    """
    with open(fname, 'r') as f:
        s = f.read()
    s = s.replace('\n', '')
    ls = len(s)
    if ls < n:
        raise ValueError
    m = 0
    for x in range(ls - n):
        t = 1
        for y in range(n):
            t *= int(s[x + y])
        if m < t:
            m = t
    print(m)

if __name__ == "__main__":
    pe8()