Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

Kindly assistance me with this code as it continues to give "None" as yield at whatever point a non leap year is input 

def is_leap(year):

if year >=1900:

    if year%4==0:

        if year%100==0:

            if year%400==0:

                print ("True")

            else:

                print ("False")

        else:

            print("True")

    else:

        print("False")

year = int(input())

print(is_leap(year))

1 Answer

0 votes
by (26.4k points)

You didn't indicate the input and the function appears to be not finished to me however in the given example when your input parameter year is under 1900 (In the second line of the function) at that point the function will not print anything.

def is_leap(year):

    if year >=1900:

        if year%4==0:

            if year%100==0:

                if year%400==0:

                    return True

                else:

                    return False

            else:

                return True

        else:

            return False

    return False

year = input()

print(is_leap(year))

Want to learn python to get expertise in the concepts of python? Join python certification course and get certified

For more details, do check out the below video tutorial...

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 17, 2021 in Java by Harsh (1.5k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...