Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add_own_book(library):
- while True:
- own_book = input("enter the name of book you own ( press enter to skip ): ")
- if own_book and own_book not in library:
- library.append(str(own_book))
- else:
- break
- return library
- def add_wish_book(wish_books):
- while True:
- wish_book = input("enter the name of book you wish to have ( press enter to skip ): ")
- if wish_book and wish_book not in wish_books:
- wish_books.append(str(wish_book))
- else:
- break
- return wish_books
- def print_BooksList(BooksList):
- for i,book in enumerate(BooksList):
- print(f"{i+1}- {book}")
- library = []
- wish_books = []
- books_to_donate = []
- print("\nWelcome to your library\n")
- # Add books to library
- add_own_book(library)
- print("\nyour library now contains: ")
- print_BooksList(library)
- # Add books you wish to have
- add_wish_book(wish_books)
- print("\nyour wish list now contains: ")
- print_BooksList(wish_books)
- print("\n")
- # Add books that you wished to have and you acquired them
- while True:
- book_wish_have = input("enter book from wish list that you have acquired (press enter to skip): ")
- if book_wish_have in wish_books:
- wish_books.remove(str(book_wish_have))
- library.append(str(book_wish_have))
- else:
- # means user pressed enter without entering any book
- break
- # Add books to donate
- while True:
- donat_book = input("\nenter name of you library you wish to donate (press enter to skip): ")
- if donat_book:
- books_to_donate.append(str(donat_book))
- library.remove(str(donat_book))
- else:
- # means user pressed enter without entering any book
- break
- print("\nyour library now contains: ")
- print_BooksList(library)
- print("\nyour wish list now contains: ")
- print_BooksList(wish_books)
- print("\nyour books to donate now contains: ")
- print_BooksList(books_to_donate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement