Someone pleeeease help me with a snippet of Python!

Discussion in 'General Chat' started by Dekker, Jan 22, 2007.

  1. #1
    I'm trying to make this function work...

    This function has one integer parameter, a year. Return True if this year is a leap year according to the Gregorian calendar, and False otherwise. A year is a leap year according to the Gregorian calendar if it is divisible by 4, except if it is a centennial year (ends with 00), in which case it is a leap year only if it is divisible by 400.

    For one, when I run it it won't display True or False (Gives value 0).

    What am I doing wrong?
     
    Dekker, Jan 22, 2007 IP
  2. bigspaces

    bigspaces Guest

    Messages:
    105
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    change the last line to:

    return ((gregorian and centennial) or (remainder and not centennial)) and True or False

    if you really want to do it all in one line.
     
    bigspaces, Mar 17, 2007 IP
  3. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #3
    Way over my head - I only looked in this thread cause I thought it was about Monty Python :eek:

    [​IMG]
     
    Kerosene, Mar 17, 2007 IP