This menu system can easily be adapted for many programs. def menuChoice(): print ("The Menu") print () print ("1. Display the Student List") print ("0. Exit")
choice = -1 while choice < 0: choice = input("Enter your choice: ") choice = int("01234".find(choice)) return choice
def editStudentListMenu(studentList): options = {0 : quit, 1 : displayStudentList, 2 : addStudent, 3 : editStudent, 4 : deleteStudent}
choice = menuChoice() while choice != 0: studentList = options[(choice)](studentList) choice = menuChoice() print ("Thank you for using the Marks Manager")
def displayStudentList(studentList): print (" your code to add a student here") return studentList
def addStudent(studentList): print (" your code to add a student here") return studentList
def changeStudent(studentList): print (" your code to change a student here") return studentList
def editStudent(studentList): print (" your code to edit a student here") return studentList
def deleteStudent(studentList): print (" your code to delete a student here") return studentList
def readFile(): print ("your code to read the file")
return studentList
def saveFile(studentData): print ("saving...")
def main(): students = readFile() displayStudentList(students) editStudentListMenu(students) saveFile(students)
if __name__ == '__main__': main() |