Skip to content

Instantly share code, notes, and snippets.

@codewithkevin
Last active April 4, 2022 22:02
Show Gist options
  • Save codewithkevin/0c01a8ab656798f6c4cf3699a0ff98f9 to your computer and use it in GitHub Desktop.
Save codewithkevin/0c01a8ab656798f6c4cf3699a0ff98f9 to your computer and use it in GitHub Desktop.
#For a year to be a leap year, it must be divisible by 4,
# unless it is also divisible by 100. However,
# it cannot be a leap year if it is divisible by 400.
year = int(input("Enter a year: "))
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
else:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
OR
if year % 4 == 0 and year % 100 == 0 and year % 400 == 0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
@codewithkevin
Copy link
Author

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment