def new_course(courses, branches): c_id = raw_input("Enter Course ID: ") while c_id == "": print "Incorrect format, Course ID cannot be blank." c_id = raw_input("Enter Course ID: ") if c_id in courses: print "\n\nERROR! Course already registered!\n\n" return c_type = raw_input("Enter course type (UG/PG): ") while not validations.c_type(c_type.upper()): c_type = raw_input("Enter course type (UG/PG): ") name = raw_input("Enter course name: ") while not validations.name(name): name = raw_input("Enter course name: ") cred = raw_input("Enter credits: ") while not validations.cred(cred): cred = raw_input("Enter credits: ") sem = raw_input("Enter sem: ") while not validations.sem(sem, c_type.upper()): sem = raw_input("Enter sem: ") br = raw_input("Enter branch: ") b_id = -1 for key in branches: if branches[key]["name"] == br: b_id = key break if b_id == -1: print "\n\nERROR! No such branch exists!\n\n" return courses[c_id] = { "c_type": c_type.upper(), "name": name, "b_id": b_id, "cred": cred, "sem": sem } print "\nCourse " + c_id + ": " + courses[c_id][ "name"] + " registered successfully.\n\n"
def modify_course(courses): c_id = raw_input("Enter course ID: ") if c_id not in courses: print "\n\nERROR! No such course exists!\n\n" return cou = courses[c_id] print "Leave the fields blank to retain old values\n\n" print "Current name:", cou["name"] name = raw_input("Enter name: ") if name != "": while not validations.name(name): name = raw_input("Enter name: ") cou["name"] = name print "Current credits:", cou["cred"] cred = raw_input("Enter Credits: ") if cred != "": while not validations.cred(cred): cred = raw_input("Enter Credits: ") cou["cred"] = cred
def new_course(courses, branches): c_id = raw_input("Enter Course ID: ") while c_id == "": print "Incorrect format, Course ID cannot be blank." c_id = raw_input("Enter Course ID: ") if c_id in courses: print "\n\nERROR! Course already registered!\n\n" return c_type = raw_input("Enter course type (UG/PG): ") while not validations.c_type(c_type.upper()): c_type = raw_input("Enter course type (UG/PG): ") name = raw_input("Enter course name: ") while not validations.name(name): name = raw_input("Enter course name: ") cred = raw_input("Enter credits: ") while not validations.cred(cred): cred = raw_input("Enter credits: ") sem = raw_input("Enter sem: ") while not validations.sem(sem, c_type.upper()): sem = raw_input("Enter sem: ") br = raw_input("Enter branch: ") b_id = -1 for key in branches: if branches[key]["name"] == br: b_id = key break if b_id == -1: print "\n\nERROR! No such branch exists!\n\n" return courses[c_id] = { "c_type": c_type.upper(), "name": name, "b_id": b_id, "cred": cred, "sem": sem } print "\nCourse " + c_id + ": " + courses[c_id]["name"] + " registered successfully.\n\n"