Advertisement
kingbode

Untitled

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