Calendar project Python 2 - loops section

Hi - I am having trouble with the Calendar project. At first it was working when I would hit “V” after the program ran. It would print the message because the Calendar is empty. Now, for some reason it’s not working. It will run up to the point where I enter “V”, but the message will not print.

#Welcome to your calender. You will be able to view, add events, update existing events, and delete existing events. 
from time import sleep, strftime
FIRST_NAME = "Gregg"
calendar = {}
def welcome():
  print ("Welcome to your calendar") + " " + FIRST_NAME + "!"
  print "Your calender is opening"
  print strftime("%A %B %d, %Y, %I:%M:%S")
  print "What would you like to do?"

def start_calendar():
  print welcome()
  start = True
  while start != 'X':
    user_choice = raw_input("A to Add, U to Update, V to View, D to Delete, X to Exit: ")
    if user_choice == 'V' and len(calendar) == 0:
      print "Your calendar is empty!"
print start_calendar()

Hey @gsawdy85!

Try setting user_choice equal to user_choice.upper(). I think what’s happening is that you are finding the upper case version of user_choice but you never assigned that to any variable or use it.


user_choice.upper() returns the value in user_choice, shifted into caps. It doesn’t mutate the value of user_choice, however, like so:

>>> user_choice = "v"
>>> user_choice.upper()
>>> user_choice

Either the return value from user_choice.upper() needs to be captured into a variable somewhere, or the comparison could be changed to include that on the left-side of the condition. :slight_smile:

1 Like