1. Write a program to input a year in 4-digit form and check whether it is a leap year or not and display proper message.
while True:
y_str = input('year: ')
try:
y_int = int(y_str)
break
except ValueError:
print('incorrect input')
if y_int % 100 == 0 and y_int % 400 == 0:
print('{} is leap'.format(y_str))
elif y_int % 4 == 0 and y_int % 100 != 0:
print('{} is leap'.format(y_str))
else:
print('{} is not leap'.format(y_str))
Comments
Leave a comment