Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5f70125

Browse files
Fixed bug
1 parent 4b1d75f commit 5f70125

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎Age-Calculator-GUI/age_calc_gui.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
root.geometry('280x300')
88
root.resizable(0,0)
99
root.title('Age Calculator')
10+
statement = Label(root)
1011

1112
# defining the function for calculating age
1213
def ageCalc():
14+
global statement
15+
statement.destroy()
1316
today = date.today()
1417
birthDate = date(int(yearEntry.get()), int(monthEntry.get()), int(dayEntry.get()))
15-
age = today.year - birthDate.year - ((today.day, today.month) < (birthDate.day, birthDate.month))
18+
age = today.year - birthDate.year
19+
if today.month < birthDate.month or today.month == birthDate.month and today.day < birthDate.day:
20+
age -= 1
1621
statement = Label(text=f"{nameValue.get()}'s age is {age}.")
1722
statement.grid(row=6, column=1, pady=15)
1823

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /