from time import sleep, strftime
from datetime import time
USER_FIRST_NAME = "Teddy"
calendar = {}
def welcome():
print("Welcome " + USER_FIRST_NAME + "." )
print("The calendar is ready to use.")
sleep(1)
print("Today is: : " + strftime("%A %B %d, %Y"))
print("Current time is: " + strftime("%H:%M:%S"))
sleep(1)
print("What would you like to do? ")
def start_calendar():
welcome()
start = True
while start:
user_choice = input("1. A -> to Add\n2. U -> to Update\n3. V -> to View\n4. D -> to Delete\n4. X -> to Exit\nChoose an Option: ")
user_choice = user_choice.upper()
if user_choice == 'V':
if len(calendar.keys()) < 1:
print("Calendar is empty.")
else:
print(calendar)
elif user_choice == 'U':
date = input("What date? ")
update = input("Enter the update: ")
calender[date] = update
print("The calendar is now updated.")
print(calendar)
elif user_choice == 'A':
event = input("Enter event: ")
date = input("Enter date (MM/DD/YYYY): ")
if len(date) > 10 or int(date[6:]) < int(strftime("%Y")):
print("An invalid Date was entered:")
try_again = input("Try Again? Y for yes, N for No: ")
try_again = try_again.upper()
if try_again == 'Y' or try_again == 'y':
continue
else:
start = False
else:
calendar[date] = event
print("Event was successfully added")
print(calendar)
elif user_choice == 'D':
if len(celendar.keys()) < 1:
print("The calendar is empty,")
else:
event = input("What event? ")
for date in calendar.keys():
if event == calendar[date]:
del calendar[date]
print("The event was successful deleted. ")
else:
print("An invalid date was entered")
elif user_choice == 'X':
start = False
else:
print("Wrong input")
start_calendar()
whenever i enter a date it keeps saying wrong input…
the year needs to be valid (2018 and beyond). The only way i can reproduce the error is by entering 2017 or earlier.
Thanks i see whats causing the problem.