ASSIGNMENT
Q.10
Q.10 Write a menu-driven Python program to perform the following operations on a list like.
Insert Element
Append Element
Extend List
Remove Element
Pop Element
Search Element
Count Element
Sort List
Reverse List
Display List
Exit
lst = [] while True: print("\n===== LIST MENU =====") print("1. Insert Element") print("2. Append Element") print("3. Extend List") print("4. Remove Element") print("5. Pop Element") print("6. Search Element") print("7. Count Element") print("8. Sort List") print("9. Reverse List") print("10. Display List") print("11. Exit") choice = int(input("Enter your choice: ")) if choice == 1: index = int(input("Enter index: ")) element = int(input("Enter element: ")) lst.insert(index, element) print("Element inserted successfully.") elif choice == 2: element = int(input("Enter element: ")) lst.append(element) print("Element appended successfully.") elif choice == 3: n = int(input("How many elements do you want to extend? ")) temp = [] for i in range(n): temp.append(int(input("Enter element: "))) lst.extend(temp) print("List extended successfully.") elif choice == 4: element = int(input("Enter element to remove: ")) if element in lst: lst.remove(element) print("Element removed successfully.") else: print("Element not found.") elif choice == 5: if len(lst) == 0: print("List is empty.") else: print("Removed Element:", lst.pop()) elif choice == 6: element = int(input("Enter element to search: ")) if element in lst: print("Element found at index", lst.index(element)) else: print("Element not found.") elif choice == 7: element = int(input("Enter element to count: ")) print("Count:", lst.count(element)) elif choice == 8: lst.sort() print("List sorted successfully.") elif choice == 9: lst.reverse() print("List reversed successfully.") elif choice == 10: print("Current List:", lst) elif choice == 11: print("Exiting Program...") break else: print("Invalid Choice! Please try again.")


