#list_maintain.py #maintain a list of ints in order int_list = [] ch = input("Add, Delete, Search, Print, Quit: ").lower() while ch not in ["q","quit"]: if ch in ["a","add"]: new_int = int(input(" Enter the integer you want to add: ")) #search for this new one's correct position in the sorted list: i = 0 while iint_list[i]: #traverse to first one bigger i += 1 int_list.insert(i,new_int) elif ch in ["s","search"]: search_int = int(input(" Enter the integer to search for in the list: ")) if search_int in int_list: print(" It's in the list. #times:", int_list.count(search_int)) print(" Found it (first) at index:", int_list.index(search_int)) else: print(" Not in the list") elif ch in ["p","print"]: for i in int_list: print(i, end=" ") print() elif ch in ["d","del","delete"]: del_int = int(input(" Enter the integer to delete from the list: ")) if del_int in int_list: where = int_list.index(del_int) del int_list[where] else: print(del_int," is not in the list") else: print("Invalid choice") ch = input("Add, Delete, Search, Print, Quit: ").lower()