LearnPy Hub
← Exceptions problems
Medium

Valid Dates Only

Read n lines that should be dates YYYY-MM-DD. Use datetime.date.fromisoformat inside try/except ValueError. Print the weekday name of each valid date (strftime('%A')) or invalid.

Input

n, then n lines.

Output

n lines.

Sample 1

Input
3
2026-11-14
2026-02-30
hello
Output
Saturday
invalid
invalid

Sample 2

Input
1
2000-01-01
Output
Saturday
solution.py
Output appears here
Valid Dates Only · Python practice problem · LearnPy Hub