We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4b1d75f commit 5f70125Copy full SHA for 5f70125
Age-Calculator-GUI/age_calc_gui.py
@@ -7,12 +7,17 @@
7
root.geometry('280x300')
8
root.resizable(0,0)
9
root.title('Age Calculator')
10
+statement = Label(root)
11
12
# defining the function for calculating age
13
def ageCalc():
14
+ global statement
15
+ statement.destroy()
16
today = date.today()
17
birthDate = date(int(yearEntry.get()), int(monthEntry.get()), int(dayEntry.get()))
- 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
21
statement = Label(text=f"{nameValue.get()}'s age is {age}.")
22
statement.grid(row=6, column=1, pady=15)
23
0 commit comments