Project Python | Command Line Calender

You can make your own calendar and even add, update and view.

For your python code, copy and paste the following:


from time import sleep, strftime
name = “Libster”calendar = {}
def welcome():    print(“Welcome, ” + name + “!”)    print(“Calendar starting…”)    sleep(1)    print (“Today is “) + strftime( “%A %B %d, %Y”)     print (“The time is “) + strftime(“%I:%M:%S”)    sleep(1)    print(“What would you like to do?”)    def start_calendar():  welcome()  start = True  while start:    user_choice = raw_input(“Please choose A to Add, U to Update, V to View, X to Exit. “)    user_choice=user_choice.upper()    if user_choice == “V”:      if len(calendar.keys()) <1:        print “Your calendar is empty”      else:        print calendar    elif user_choice == “U”:        date = raw_input(“What date? “)        update = raw_input(“Enter the update: “)        calendar[date] = update        print(“Update successful.”)        print calendar    elif user_choice == “A”:        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.”)              try_again = raw_input(“Try again? Y for Yes, N for No: “)            try_again = upper.try_again()            if try_again == “Y”:                continue            else:                start = False            else:            calendar[date] = event            print(“Event update successful.”)            print calendar    elif user_choice == “D”:        if calendar.keys(len(date)) < 1: #check this line if fail            print(“The calendar is empty.”)        else:            event = raw_input(“What event?”)             for date in calendar.keys():                if event == calendar[date]:                     del calendar[date] # deletes entire entry, inc date & event                print(“Event deleted.”)                print calendar            else:                print(“Incorrect date.”)    elif user_choice == “X”:        start = False    else:        print(“Invalid command.”)        breakstart_calendar()


 

Then in the command line, play your python code.

Screen Shot 2017-07-02 at 17.40.47

Above, the picture is an example of how it should turn out to be. I added an event, updated that same event and viewed! Don’t forget to try to experiment and maybe make this cooler.

Yours truly,

L.O.A.S.H

Advertisements