#๐ Leap year calculation
21 messages ยท Page 1 of 1 (latest)
@signal kite
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
You aren't accounting just for ordinary years divided by 4, you've made your conditions too specific
ur correct in ur own way , the problem is with ques , the question assumes that only numbers above 400 will be asked
so if u go for a no. lower than 400 , code says remainder is not zero and hence it is not a leap year
that's not quite the issue. A leap year calculator should work for any number above 0
ur conditions doesnt allow it to work below 400 then
a leap year is a year which is a multiple of 4
and as fashoomp said it should work for any number above 0 (even below 0 would work but wouldnt make sense)
yes hes right , but the condition of divisibility by 100 and 400 is assumed in the question
that's how leap years work
any number divisible by 4, except for 100s, unless it's divisible by 400
1500 and 1700 are not leap years, even though they're divisible by 4
but 1600 is
ah okay thanks, this seems to work now:
year = int(input("Please type in a year: " ))
if year % 4 == 0 and year % 100 == 0:
if year % 400 == 0:
print("That year is a leap year.")
else:
print("That year is not a leap year.")
elif year % 4 == 0:
print("That year is a leap year.")
else:
print("That year is not a leap year.")
yeah, that's looking good now
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
