Skip to content

Commit 22c659e

Browse files
authored
Merge pull request Astrodevil#352 from KouluruNandaKishoreReddy/Add-Birthday-Wish-Calculator.py
Birthday wish calculator.py
2 parents 8f51b88 + bb8b55c commit 22c659e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Python/Birthday wish calculator.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import datetime
2+
current_date=datetime.date.today().strftime('%Y-%m-%d')
3+
current_date_ist=current_date.split('-')
4+
b_date=input("Enter birthday date in year-month-date format : ")
5+
name=input("Name of birthday legend : ")
6+
b_date=b_date.split('-')
7+
if current_date_ist[1] == b_date[1] and current_date_ist[2] == b_date[2] :
8+
age=int(current_date_ist[0]) - int(b_date[0])
9+
ordinal_suffix={1 : 'st',2 : 'nd',3 : 'rd',11 : 'th',12 : 'th',13 : 'th'}.get(age % 10 if not 10 < age <= 13 else age % 14,'th' )
10+
print(f" it's {name}'s {age}{ordinal_suffix} birthday" )
11+
else:
12+
print("sorry today is not your birthday")
13+
14+
#Please enter your date of birth year-month-date format

0 commit comments

Comments
 (0)