Codeacademy pro comand line calculator not working what is wrong with my code?


#1

https://www.codecademy.com/courses/learn-python/projects/calendar

"""An interactive calculator"""
from time import sleep, strftime
name = "FK"
calendar = {}

def welcome():
  print "Welcome, " + name + "."
  sleep(1)
  print "Today is: " + strftime("%A %B %d, %Y")
  print "The 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 = raw_input("A to Add, U to update, V to view, D to delete, X in exit: ")
      user_choice = user_choice.upper()
      if user_choice == 'V':
        if len(calendar.keys()) < 1:
            print "Calendar empty"
        else:
            print calendar
      elif user_choice == 'U':
        date = raw_input("Whats the date: ")
        update = raw_input("Enter the update: ")
        calendar[date] = update
        print "updated succesfully"
        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[5:]) < int(strftime("%Y")):
          print "invalid date"
          try_agian = "Try Again? Y for Yes, N for No:" 
          try_again = try_again.upper()
          if try_agian == '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 "calendar is empty"
        else:
            event = raw_input("What event?")
            for date in calendar.keys():
              if event == calendar[date]:
                del calendar[date]
                print "event deleted"
              else:
                  print "incorrect event specified"
      elif user_choice == 'X':
        start = False
      else:
          print "invalid command"
          start = False
          
  start_calendar()

#2

the last line of your code:

start_calendar()

is the function call, which executes the function. Except its nested inside a function, so its never reached.