Advertisement
kingbode

Untitled

Sep 23rd, 2023
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.98 KB | None | 0 0
  1.  
  2.  
  3. def add_own_book(library):
  4.     while True:
  5.         own_book = input("enter the name of book you own ( press enter to skip ): ")
  6.         if own_book and own_book not in library:
  7.             library.append(str(own_book))
  8.         else:
  9.             break
  10.  
  11.     return library
  12.  
  13.  
  14. def add_wish_book(wish_books):
  15.     while True:
  16.         wish_book = input("enter the name of book you wish to have ( press enter to skip ): ")
  17.         if wish_book and wish_book not in wish_books:
  18.             wish_books.append(str(wish_book))
  19.         else:
  20.             break
  21.  
  22.     return wish_books
  23.  
  24. def print_BooksList(BooksList):
  25.     for i,book in enumerate(BooksList):
  26.         print(f"{i+1}- {book}")
  27.  
  28.  
  29.  
  30.  
  31. library = []
  32. wish_books = []
  33. books_to_donate = []
  34.  
  35. print("\nWelcome to your library\n")
  36. # Add books to library
  37. add_own_book(library)
  38. print("\nyour library now contains: ")
  39. print_BooksList(library)
  40.  
  41. # Add books you wish to have
  42. add_wish_book(wish_books)
  43.  
  44. print("\nyour wish list now contains: ")
  45. print_BooksList(wish_books)
  46.  
  47. print("\n")
  48.  
  49. # Add books that you wished to have and you acquired them
  50. while True:
  51.     book_wish_have = input("enter book from wish list that you have acquired (press enter to skip): ")
  52.     if book_wish_have in wish_books:
  53.         wish_books.remove(str(book_wish_have))
  54.         library.append(str(book_wish_have))
  55.     else:
  56.         # means user pressed enter without entering any book
  57.         break
  58.  
  59.  
  60. # Add books to donate
  61. while True:
  62.     donat_book = input("\nenter name of you library you wish to donate (press enter to skip): ")
  63.     if donat_book:
  64.         books_to_donate.append(str(donat_book))
  65.         library.remove(str(donat_book))
  66.     else:
  67.         # means user pressed enter without entering any book
  68.         break
  69.  
  70.  
  71. print("\nyour library now contains: ")
  72. print_BooksList(library)
  73.  
  74. print("\nyour wish list now contains: ")
  75. print_BooksList(wish_books)
  76.  
  77. print("\nyour books to donate now contains: ")
  78. print_BooksList(books_to_donate)
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement