Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 19, 2017 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/e0af7d8a245238d6625bd38247ddaa18 to your computer and use it in GitHub Desktop.
Save codecademydev/e0af7d8a245238d6625bd38247ddaa18 to your computer and use it in GitHub Desktop.
Codecademy export
#I programmed this to make a Calender project
from time import strftime
USER_FIRST_NAME = "User"
calender = {}
def welcome():
print "Welcome to your Calender" + USER_FIRST_NAME + "."
print "Calender starting..."
sleep(1)
print "Today's date: " + strftime("%A %B %d, %XY")
sleep(1)
print "Current time: " + strftime("%H, %M, %S")
sleep(1)
def start_calender():
welcome
start = True
while start:
user_choice = raw_input("A to Add, U to Update, V to view, D to Delete, X to Exit")
user_choice = user_choice.upper()
if user_choice == 'V':
if len(calender.keys()) < 1:
print "Calendar empty."
else:
print calender
elif user_choice == 'U':
date = raw_input("What date?: ")
update = raw_input("Enter the update: ":
calender[date] = update
print "Update successful"
print calender
event = raw_input("Enter event: ")
date = raw_input("Enter date (MM/DD/YYYY): ")
if(len(date) > 10 or int(date[6:]) < int(strftime ("%Y"))):
print "Invalid date was entered"
try_again = raw_input("Try again? Y for Yes, N for No: ")
try_again = try_again.upper()
if try_again == 'Y'
continue
else:
start = False
else:
calendar[date] = event
print "Update sucess"
print calender
elif user_choice == 'D':
if len(calender.keys()) < 1:
print "Calender is empty"
else:
event = raw_input("What event?: ")
for date in calender.keys():
if event == calender[date]:
del (calender[date]
print "Event succesfully deleted"
print calendar
else:
print "Invalid event was specified"
elif user_choice == 'X':
start = False
else:
print "Invalid command"
break
start_calender()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment