#๐Ÿ”’ Leap year calculation

21 messages ยท Page 1 of 1 (latest)

signal kite
#

I am confused as to what I am supposed to change in this exercise. this

green wharfBOT
#

@signal kite

Python help channel opened

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.

echo canopy
neon jungle
#

so if u go for a no. lower than 400 , code says remainder is not zero and hence it is not a leap year

echo canopy
#

that's not quite the issue. A leap year calculator should work for any number above 0

neon jungle
covert sundial
#

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)

neon jungle
echo canopy
#

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

neon jungle
#

hmm

#

I see

signal kite
#

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.")
echo canopy
#

yeah, that's looking good now

green wharfBOT
#
Python help channel closed

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.