🔒 Closed Your age

Status
Not open for further replies.

AraAra

Honorary Poster
Code:
import datetime
now = datetime.datetime.now()
leap = 0
# Enter date as DD/MM/YYYY e.g. 21/09/1999
try:
    yd = list(map(int, input().split('/')))
    if 0 in yd:
        print("Date, month or year can't be zero.")
        quit()
    f_date = datetime.date(yd[2], yd[1], yd[0])
    l_date = datetime.date(now.year, now.month, now.day)
    delta = (l_date - f_date).days
    if delta < 0:
        print("Don't enter future date")
    else:
        for i in range(yd[2], now.year+1):
            if (i%4==0 and i%100==0 and i%400==0 or i%4==0 and i%100!=0):
                leap = leap+1
        if delta//365 > 100:
            print("You might be dead. Anyway")
        print("You are "+str(delta//365)+" Years", str(delta%365//30)+" Months &", str((delta%365%30))+" Days older")
except IndexError:
    print("Enter proper date format e.g. 21/09/1999")
except ValueError:
    print("Who told you that date contains alphabets or special characters?")
except:
    print("Try Again!")

This is my favorite code From Sololearn
 
Ito po pala yung HTLM
Code:
<!DOCTYPE html>
<html>
    <head>
        <title>Color switch</title>
        <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>
    </head>
    <body></body>
</html>
Example lang po
 
Status
Not open for further replies.

About this Thread

  • 13
    Replies
  • 820
    Views
  • 7
    Participants
Last reply from:
Maria Malumanay

Trending Topics

Online now

Members online
1,150
Guests online
1,018
Total visitors
2,168

Forum statistics

Threads
2,274,693
Posts
28,957,671
Members
1,233,403
Latest member
uradox
Back
Top