while True: try: y=int(input()) if (y%4==0 and not y%100==0) or y%400==0: print("閏年") else: print("平年") except: break
記得用try和except!