def processCommand(): print("Enter the option you want to search by") print("1.Title") print("2.Number") print("3.Subjects") print("4.Other") inp = input() search_result = [] if (inp == "Title"): input_title = input("Enter the title to be searched") se = SearchEngine() search_result = se.search_by_title(input_title) display_main(search_result) elif (inp == "Number"): input_number = input("Enter the number to be searched ") se = SearchEngine() search_result = se.search_by_call_number(input_number) display_main(search_result) elif (inp == "Subjects"): input_subjects = input ("Enter the subject to be searched") se = SearchEngine() search_result = se.search_by_subjects(input_subjects) display_main(search_result) elif (inp == "Other"): input_other= input("Enter the data to be searched ") se = SearchEngine() search_result = se.search_by_other(input_other) display_main(search_result) yesno = input ("Do you wish to continue? Yes or No") if (yesno == "Yes"): processCommand() elif(yesno == "No"): exit
def main(): se = SearchEngine() results = [] ch = "y" while(ch=="y"): print("Menu\n1.Search by call number\n2.Search by Title\n3.Search by subject\n4.Search by other\n5.exit\n") print("Enter search number :") choice = input() if choice=="1": #print("first choice") string = input("Enter String :") results = se.search_by_call_number(string) for count in range(len(results)): results[count].display() #print(len(results)) del results[:] elif choice=="2": string = input("Enter String :") results = se.search_by_title(string) for count in range(len(results)): results[count].display() #print(len(results)) del results[:] elif choice=="3": string = input("Enter String :") results = se.search_by_subject(string) for count in range(len(results)): results[count].display() #print(len(results)) del results[:] elif choice=="4": string = input("Enter String :") results = se.search_by_other(string) for count in range(len(results)): results[count].display() #print(len(results)) del results[:] elif choice=="5": print("Exited") break else: print("Invalid choice ") ch = input("Do you want to continue ?(y/n)")