Count number of days in a given month of a year

    0

    1

    CrypticSai-08

    #take user inputs for Month and year in integer
    Month = int(input('Enter the Month :'))
    Year = int(input('Enter the Year :'))
    #Check condition for Month and leap year
    if(Month == 2 and (Year%400 == 0) or ((Year%100 != 0) and (Year%4 == 0))):
        #if condition is TRUE
        print('Number of days is 29')
    #if False check for other conditions
    elif(Month == 2):
        print('Number of days is 28')
    elif(Month == 1 or Month == 3 or Month == 5 or Month == 7 or Month == 8 or Month == 10 or Month == 12):
        print('Number of days is 31')
    else:
        print('Number of days is 30')
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.