We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Python
  3. Introduction
  4. Write a function
  5. Discussions

Write a function

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 2211 Discussions, By:

recency

Please Login in order to post a comment

  • jainishachoksi41
    13 hours ago+ 0 comments

    def is_leap(year):

    # Write your logic here
    if (year%4 == 0):
        if (year % 100 == 0):
            if (year% 400 == 0):
                return True
            return False
        return True
    return False
    

    year = int(input()) print(is_leap(year))

    0|
    Permalink
  • imranatif003
    2 days ago+ 1 comment

    if(year % 4 == 0 and year % 400 == 0 and year % 100 != 0): print(True) else: return leap

                Hello Guys, my this code passes the 3 test cases, can anyone tell me how to solve the all cases?
    
    0|
    Permalink
  • akhilesh_jangid1
    2 days ago+ 0 comments

    if year % 100 == 0: if year % 400 != 0: return False else: return True elif year % 4 == 0: return True else: return False

    0|
    Permalink
  • akhilesh_jangid1
    2 days ago+ 0 comments

    if year % 100 == 0: if year % 400 != 0: return False else: return True elif year % 4 == 0: return True else: return False

    0|
    Permalink
  • Chillpill9797
    2 days ago+ 0 comments

    def is_leap(year): leap = False

    if year % 4 == 0:
        if year % 100 == 0:
            if year % 400 == 0:
                leap = True
        else:
            leap = True
    
    return leap
    

    year = int(input()) print(is_leap(year))

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy