I encountered some troubles in running my calendar


#1

here is all my codes


"""
  this is a command line calendar the user is able to 
View the calendar
Add an event to the calendar
Update an existing event
Delete an existing event
  the program should
  1.Print a welcome message to the user
  2.Prompt the user to view, add, update, or   3.delete an event on the calendar
  Depending on the user's input: view, add, update, or delete an event on the calendar
  4.The program should never terminate unless the user decides to exit
"""
from time import sleep
from time import strftime

user_name = input("What is your name? ")

calendar = {}


def welcome():
    print("Welcome, " + user_name + ".")
    print("The calendar is opening...")
    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("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(calendar.keys()) < 1:
                print("calendar is empty")
        elif user_choice == 'U':
            date = input("What date?")
            update = input("Enter the update: ")
            calendar[date] = update
            print("the update is successful")
            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("invalid message is entered")
                try_again = 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(calendar)
        elif user_choice == "D":
            if len(calendar.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 is successfully deleted")

                    else:
                        print(" an incorrect event was specified.")
        elif user_choice == "X":
            start = False
        else:
            print("invalid command was entered")



start_calendar()

I did some modification to run in a python 3 IDE, however, it does not print out the current date and current time? I used pycharm as my IDE and it did not prompt me to leave my name either, it just showed a “?”


#2

when doing what action?

i put your code here:

https://repl.it/@stetim94/InsubstantialUglyBlackpanther


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.