Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 leap year program issue

Can someone please help with the following program.

Can't seem to figure out where I am going wrong.

My program executes fine, just ends up giving the wrong result. Ex. 1992 is a leap year, but my program shows it's not.

a = int(input("Enter year : "))

if (a % 4) == 0:

   if (a % 100) == 0:

       if (a % 400) == 0:

           print("Tis is leeap year")


           print("not a leap year")


       print("not a leapp year")


   print("No it ain't")
the logic looks wrong to me. the 100 year test is supposed to be different than the 400 year test. but yours are coded alike.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
How about calendar.leap?

>>> import calendar

>>> calendar.isleap(1992)
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
Line 17 is wrong (the one with 'leapp'). That line is only triggered if the year is divisible by 4, but it says that the year is not a leap year. Also, it would be clearer if you called your variable 'year' rather than 'a'.
Craig "Ichabod" O'Brien -
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures


Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Facing issue with pyautogui program after PC upgrade Utkarsh29 2 529 Jul-15-2019, 05:20 PM
Last Post: Utkarsh29
  Creating folders dynamically with year/month/date sritsv 0 2,853 Oct-16-2017, 03:44 PM
Last Post: sritsv
  Calculating what year it is when you are 100 years old dankim9000 2 5,349 Apr-26-2017, 08:03 PM
Last Post: dankim9000
  Leap Year MartinEvtimov 14 11,395 Mar-10-2017, 01:46 AM
Last Post: Larz60+
  Logic to convert an integer to YEAR / MONTH hugobaur 9 2,990 Oct-18-2016, 11:58 AM
Last Post: hugobaur

Forum Jump:

Users browsing this thread: 1 Guest(s)