forked from HarshCasper/Rotten-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounting_days.py
44 lines (37 loc) · 1.17 KB
/
counting_days.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# import modules like 'os' and 'date'
import os
from datetime import date
# clear the console
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
print("\nWelcome to Counting Days!\n")
# get the current day
today = date.today()
print("\nCurrent Day: ", today)
# User input for the date
print("\nTell me about the day you wanted...")
try:
year = int(input("What Year? "))
except ValueError:
raise ValueError("Invalid Year! You must enter a number for the year.")
try:
month = int(input("What Month? "))
except ValueError:
raise ValueError("Invalid Month! You must enter a number for the month.")
try:
day = int(input("What Day? "))
except ValueError:
raise ValueError("Invalid Day! You must enter a number for the day.")
# try to build the date object
try:
futureday = date(year, month, day)
except ValueError:
raise ValueError("Invalid Date! You must enter a valid date.")
# Display message if date is before today.
if today > futureday:
raise ValueError("Invalid Date! You must pick a future date.")
# calculate and show date
delta = futureday - today
print("\nThere are", delta.days, "days between", today, "and", futureday, "!")