Skip to content

Commit f44458b

Browse files
author
Chloe White
committed
error handling
1 parent f4da83f commit f44458b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

calendar_display/calendar_app.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,17 @@ def display_calendar(year):
3333
messagebox.showinfo(f"Calendar for {year}", cal_str)
3434
except ValueError:
3535
messagebox.showerror("Invalid Input", "Please enter a valid positive year")
36+
37+
38+
def show_calendar(year):
39+
try:
40+
year = int(year)
41+
if year < 1:
42+
raise ValueError
43+
cal = calendar.TextCalendar()
44+
cal_str = cal.formatyear(year)
45+
messagebox.showinfo(f"Calendar for {year}", cal_str)
46+
except ValueError:
47+
messagebox.showerror("Invalid Input", "Please enter a valid positive year")
48+
49+
display_calendar(year)

0 commit comments

Comments
 (0)