Page 52 - ipp11
P. 52

else:
                              copies = int(input("Enter number of copies: "))
                              library[book] = copies
                              print("Book added successfully.")
                   elif choice == 'b':
                        book = input("Enter book title to update: ")
                        if book in library:
                              new_copies = int(input("Enter updated number of copies: "))
                              library[book] = new_copies
                              print("Book stock updated.")
                        else:
                              print("Book not found in the library.")
                   elif choice == 'c':
                        book = input("Enter book title to issue: ")
                        if book in library:
                              if library[book] > 0:
                                    library[book] -= 1
                                    print("Book issued successfully.")
                              else:
                                    print("No copies left to issue.")
                        else:
                              print("Book not found.")
                   elif choice == 'd':
                        if library:
                              print("\nBooks in Library (sorted):")
                              for title in sorted(library):
                                    print("Title:", title, library[title], "copies")
                        else:
                              print("Library is empty.")
                   elif choice == 'e':
                        print("Exiting program")
                        break
                   else:
                        print("Invalid choice! Please enter a letter from a to e.")
































                                                       M.22
   47   48   49   50   51   52   53   54   55   56   57