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"
  sleep(1)
  print strftime("%A %B %d, %Y, %I:%M:%S")
  sleep(1)
  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: ")
    user_choice.upper()
    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.

Precisely.

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()
'V'
>>> user_choice
'v'
>>> 

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