Last active
May 21, 2024 19:50
-
-
Save luabida/1bf60912bbbadadec19f1f691a8502da to your computer and use it in GitHub Desktop.
Calculate age
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime as dt | |
calculate_age = ( | |
lambda bd: ( | |
(td := dt.today()) and (td.year - bd.year - ((td.month, td.day) < (bd.month, bd.day))) | |
)) | |
print(f"{calculate_age(dt(1990, 5, 21))}yo") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment