def find_leap(year): if (year % 100 != 0 and year % 4 == 0) or (year % 100 == 0 and year % 400 == 0): return True return FalseNot tested.
I would create the test file with an editor as it is not required, at least in your spec above
To read the file, use:
with open('all_years.txt') as f: year = f.readlines() if find_leap(year.strip()): # ... add print here