ASSIGNMENT
Q.12
Q.12 Write a menu-driven Python program to maintain a list of movie names. to Perform:
Add movie
Insert movie at position
Delete movie
Rename movie
Count total movies
Search movie
Sort movies
Reverse moviesĀ
movies = [] while True: print("\n===== MOVIE MENU =====") print("1. Add Movie") print("2. Insert Movie at Position") print("3. Delete Movie") print("4. Rename Movie") print("5. Count Total Movies") print("6. Search Movie") print("7. Sort Movies") print("8. Reverse Movies") print("9. Display Movies") print("10. Exit") choice = int(input("Enter your choice: ")) if choice == 1: movie = input("Enter movie name: ") movies.append(movie) print("Movie added successfully.") elif choice == 2: position = int(input("Enter position: ")) movie = input("Enter movie name: ") movies.insert(position, movie) print("Movie inserted successfully.") elif choice == 3: movie = input("Enter movie name to delete: ") if movie in movies: movies.remove(movie) print("Movie deleted successfully.") else: print("Movie not found.") elif choice == 4: old_movie = input("Enter movie name to rename: ") if old_movie in movies: new_movie = input("Enter new movie name: ") index = movies.index(old_movie) movies[index] = new_movie print("Movie renamed successfully.") else: print("Movie not found.") elif choice == 5: print("Total Movies:", len(movies)) elif choice == 6: movie = input("Enter movie name to search: ") if movie in movies: print("Movie found at position", movies.index(movie) + 1) else: print("Movie not found.") elif choice == 7: movies.sort() print("Movies sorted successfully.") elif choice == 8: movies.reverse() print("Movie list reversed successfully.") elif choice == 9: if len(movies) == 0: print("Movie list is empty.") else: print("\nMovie List:") for i in range(len(movies)): print(i + 1, ".", movies[i]) elif choice == 10: print("Exiting Program...") break else: print("Invalid Choice! Please try again.")


