-
-
Save codecademydev/c5b350b65662132a6521ade6b5292be0 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This program will allow users to interact with a calendar""" | |
from time import sleep, strftime | |
user_first_name = "William" | |
calendar = [] | |
def welcome(): | |
print "Hello " + user_first_name + " , welcome to your calendar!" | |
print "The calendar is opening!" | |
sleep(1) | |
print "The local date is: " + strftime("%A, %B, %d, %Y") | |
print "The local time is: " + strftime("%I, %M, %S, %p") | |
sleep(1) | |
print "What would you like to do?" | |
def start_calendar(): | |
welcome() | |
start = True | |
while start == True: | |
user_choice = raw_input("A to Add, U to Update, V to View, D to Delete: ") | |
user_choice.upper() | |
if user_choice == 'V': | |
if len(calendar.keys()) < 1: | |
print "The calendar is empty!" | |
else: | |
print calendar | |
elif user_choice == "U": | |
date = raw_input("What date? ") | |
update = raw_input("Please enter the update: ") | |
calendar[date] = update | |
print "The update was successful!" | |
print calendar | |
elif user_choice == "A": | |
event = raw_input("Please enter the event: ") | |
date = raw_input("Please enter the date in the MM/DD/YYYY format: ") | |
if len(date) > 10 or int(date[6:]) < int(strftime("%Y")): | |
print "You've entered an invalid date!" | |
try_again = raw_input("Would you like to try again? (Y/N)") | |
try_again = try_again.upper() | |
if try_again == 'Y': | |
continue | |
else: | |
start = False | |
else: | |
calendar[date] = event | |
print "Event added successfully!" | |
print calendar | |
elif user_choice == "D": | |
if len(calendar.keys()) < 1: | |
print "The calendar is empty!" | |
else: | |
print calendar | |
event = raw_input("What is the event: ") | |
for date in calendar.keys(): | |
if event == calendar[date]: | |
del calendar[date] | |
print "The event was successfully deleted!" | |
else: | |
print "That event does not exist, be sure to enter the event exactly as it appears!" | |
elif user_choice == "X": | |
start = False | |
else: | |
print "An invalid command was entered, please try again!" | |
start = False | |
start_calendar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment