Command Line Calendar: I'm stuck


I've been debugging, but I got to a point where I just cannot get it to work.

I continue to get the error "line 56 continue not properly in loop"

I get that it's saying it's not properly in the while loop, but I am not sure how to get it right.

I have tried moving it, but then I get indent issues. I am stumped.

from time import sleep, strftime

calendar = {}

def welcome():
    print("Welcome, " + USERNAME + ".")
    print("Calendar starting...")
    print("Today is: ")
    strftime("%A %B %d, %Y")
    print("Current time is: ")
    print("What would you like to do?")
def start_calendar():
    start = True
    while start: 
        user_choice = raw_input("Enter 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 empty.")
            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":
                start = False    
            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.")
            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
                print("Incorrect date.")
    elif user_choice == "X":
        start = False
        print("Invalid command.")


This is your while loop:

while start: 
    user_choice = raw_input("Enter A to Add, U to Update, V to View, D to Delete, X to Exit: ")

That's it. This is your loop, infinite loop with a single line of code inside the block. Error message states that you have continue statement outside the loop. And I see few more break and continue statements.

You just need to increase level of indentation ->


Thank you for your help. I now see where I went horribly wrong! LOL

One wrong indent and boy everything goes haywire. Being able to see it with the lines made me understand where things properly start and end too!


Glad I could help :slight_smile: You're very welcome!

In most code editors there is an option "show invisibles", it renders placeholders for tabs, spaces, and newlines. Extremely helpful, especially in Python :slight_smile:


Also, that site is REALLY handy, too! Great resource!


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