Skip to content

Commit 631e75c

Browse files
committed
Adgust the age calculation.
1 parent a06231e commit 631e75c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎sprint5-prep-exercises/data_class.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ class Person:
88
date_of_birth: date
99
preferred_operating_system: str
1010

11-
def is_adult(self):
11+
def is_adult(self) -> bool:
1212
today = date.today()
1313
age = today.year - self.date_of_birth.year
1414

15+
if (today.month, today.day) < (
16+
self.date_of_birth.month,
17+
self.date_of_birth.day
18+
):
19+
age -= 1
20+
1521
return age >= 18
1622

1723

0 commit comments

Comments
 (0)