Calendar project


#1

Can someone tell me what is wrong with my code? I kept getting the same indentation error ("IndentationError: unindent does not match any outer indentation level") . I went through and redid the exercise a few times. Now I pasted the code, it just messed up the indentation I had.

"""
Building a calendar where the user can view, add, update and delete an event
"""

from time import sleep
from time import strftime
USER_FIRST_NAME = "MJ"
calendar = {}

def welcome():
  	print "Welcome, " + USER_FIRST_NAME + "."
  	print "Calendar is starting"
 		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 = raw_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."
            else:
              	print calendar
        
        elif user_choice == "U":
          	date = raw_input("What date? ")
            update = raw_input("Enter the update: ")
            calendar[date] = update
           	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 entered"
                try_again = raw_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 "Event added"
                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"
                        print calendar
                    else:
                      	print "Incorrect event entered"
         
        elif user_choice == "X":
          	start = False
            
        else:
          	print "Invalid command entered"
            start = False

start_calendar()

#2

in the beginning:

  	print "Calendar is starting"
 		sleep(1)
		print "Today is: " + strftime("%A $B $d, %Y")
  	print "Current time is: " + strftime("%H:%M:%S")

why do sleep and the print below have additional indent? They shouldn't. Please use markup to make indent show on the forum, rather important in such a question:


#3

it looks fine on the project site itself. it got messed up when I pasted it
in


#4

this why i said you should post with markup, so i can really see what the problem is. I can't solve an indent error, if the code gets messed up thanks to copying. For all i care, you put the code in a gist, and link to the gist. (github gist)


#5

​Ok. I found out what caused the error. I formatted the code manually (by 4
spaces for each indent) not by the automatic setup in the exercise panel,
which appears 2 spaces for each indent. Anyway, thanks for a quick response
on this. ​


#6