daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Calendar'
  2.  
  3. from time import sleep, strftime
  4.  
  5. grace = 'Grace'
  6.  
  7. calendar = {
  8.  
  9. }
  10.  
  11. def welcome():
  12.   print 'Welcome ' + grace  + '!'
  13.   print 'Calendar is opening...'
  14.   sleep(1)
  15.   print 'Today is ' + strftime('%A %B %d, %Y')
  16.   print strftime('%H:%M:%S')
  17.   sleep(1)
  18.   print 'What would you like to do?'
  19.  
  20. def start_calendar():
  21.   welcome()
  22.   start = True
  23.   while start:
  24.     user_choice = raw_input('A to Add, U to Update, V to View, D to Delete, X to Exit: ')
  25.     user_choice = user_choice.upper()
  26.     if user_choice == 'V':
  27.       if len(calendar.keys()) == 0:
  28.         print 'Your calendar is empty.'
  29.       else:
  30.         print calendar
  31.     elif user_choice == 'U':
  32.       date = raw_input('What date? ')
  33.       update = raw_input('Enter the update: ')
  34.       calendar[date] = update
  35.       print 'Update successful!'
  36.       print calendar
  37.     elif user_choice == 'A':
  38.       event = raw_input('Enter event: ')
  39.       date = raw_input('Enter date (MM/DD/YYYY): ')
  40.       if int(len(date)) != 10 or int(date[6:]) < int(strftime('%Y')):
  41.         print 'Invalid entry.'
  42.         try_again = raw_input('Try again? Y for Yes, N for No: ')
  43.         try_again = try_again.upper()
  44.         if try_again == 'Y':
  45.           continue
  46.         else:
  47.           start = False
  48.       elif int(date[0:1]) <= int(strftime('%m')) and int(date[3:4]) < int(strftime('%d')) and int(date[6:]) == int(strftime('%Y')):
  49.         print 'Invalid entry.'
  50.         try_again = raw_input('Try again? Y for Yes, N for No: ')
  51.         try_again = try_again.upper()
  52.         if try_again == 'Y':
  53.           continue
  54.         else:
  55.           start = False
  56.       else:
  57.         calendar[date] = event
  58.         print 'Event was succesfully added!'
  59.         print calendar
  60.     elif user_choice == 'D':
  61.       if len(calendar.keys()) < 1:
  62.         print 'Your calendar is empty.'
  63.       else:
  64.         event = raw_input('What event? ')
  65.         for date in calendar.keys():
  66.           if event == calendar[date]:
  67.             del calendar[date]
  68.             print 'Event was succesfully deleted.'
  69.             print calendar
  70.           else:
  71.             print 'Incorrect event.'
  72.     elif user_choice == 'X':
  73.       start = False
  74.     else:
  75.       print 'Invalid command entered.'
  76.       start = False
  77.              
  78. start_calendar()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top