Skip to content

Commit 9b3ad1e

Browse files
committed
These are the changes i made in method is_adult()
1 parent 63968ad commit 9b3ad1e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

prep exercises/dataclasses_exercise.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ def is_adult(self):
1212
birth_date = date.fromisoformat(self.date_of_birth)
1313
age = today_date.year - birth_date.year
1414

15+
if (today_date.month, today_date.day) < (birth_date.month, birth_date.day):
16+
age -= 1
17+
1518
return age >= 18
1619

1720

18-
imran = Person("Imran", "2019-10-18", "Ubuntu")
21+
imran = Person("Imran", "2007-11-02", "Ubuntu")
1922

2023
print(imran.is_adult())

0 commit comments

Comments
 (0)