Cant figure out what ive done wrong with my code


I am getting syntax errors all over the place, ive tried to indent code both ways knowing its 4 spaces needed for indentation.

I was expecting it to work, since ive been trying to debug the program as i go.

""" Now we are going to make a command line calendar."""
from time import sleep, strftime
username = "Stian"

calendar = {}

def welcome():
  	print "Welcome" + username
  	print "Calendar is opening"
  	print "Today is: " + strftime("%A %B %d, %Y")
  	print "Time is: " + strftime("%H:%M:%S")
  	print "What would you like to do?"
def start_calendar():
  	start = True
  	while start:
    		user_choice = raw_input("A to Add, U to Update, V to View, D to Delete, X to Exit ")
    		if user_choice == "V":
      			if len(calendar.keys()) < 1:
        				print "The calendar is empty"
        				print calendar
   			elif user_choice == "U":
      			date = raw_input("What date?: ")
      			update = raw_input("Enter the update: ")
      			calendar.update(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:10]) < int(strftime("%Y")):
        				print "Invalid date entered"
        				try_again = raw_input("Try Again? Y for Yes, N for No: ")
        				if try_again == "Y":
          			    start = False
        				calendar[date] = event
       					print "Event successfully added.."
          			print calendar
    		elif user_choice == "D":
      			if calendar.keys() < 1:
              	print "Calendar is empty"
        				event = raw_input("What event?: ")
        				for date in calendar.keys():
          					if event == calendar[date]:
            						del calendar[date]
            						print "Successfully deleted"
            						print calendar
            						print "Incorrect event specified"
     		elif user_choice == "X":
      			start = False
      			print "Invalid command given"


I see it now! indentation is way off, the learning platform seems to be off in how it shows the indentation.

okay, so i fixed the indentation. But now its giving me syntax errors on my firste elif statement.


The code you posted is mixing tabs and spaces. Use only spaces or only tabs (4 spaces are preferred)


So does the code look ok besides that ?


If you want someone to judge your code then fix up the things you already know are bad


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