def add_books(self): if not self.info_confirm('1'): return while True: book = Book() book_id = str(random.randint(100000, 999999)) while book_id in self.df_books.book_id.values: book_id = random.randint(100000, 999999) book.book_id = book_id ISBN = input("Please enter ISBN of the book: ") book.ISBN = ISBN title = input("Please enter title of the book: ") book.title = title.capitalize() author = input("Please enter author of the book: ") book.author = author.capitalize() publisher = input("Please enter publisher of the book: ") book.publisher = publisher.capitalize() language = input("Please enter language of the book: ") book.language = language while True: date = input("Please enter publication_date of the book(Mon/Day/Year): ") try: datetime.strptime(date, "%m/%d/%Y") book.publication_date = date break except ValueError: print("Oops! That was no valid date. Try again...") row = len(self.df_books) for a in [attr for attr in dir(book) if not attr.startswith('__')]: self.df_books.loc[row, [a]] = getattr(book, a) print("The following book has been added to the library:") print(self.df_books[-1:].to_string(index=False)) print(""" ===========Please Select=========== 1. Keep adding books Any. Exit """) choice = input("Please enter your choice: ") if choice == '1': continue else: break