Advertisement
Spocoman

Old Books

Oct 13th, 2023 (edited)
702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. book = input()
  2. book_count = int(input())
  3. is_found = False
  4. counter = 0
  5.  
  6. for i in range(book_count):
  7.     command = input()
  8.     if command == '' or command == "No More Books":
  9.         break
  10.     elif command == book:
  11.         print(f"You checked {counter} books and found it.")
  12.         is_found = True
  13.         break
  14.     counter += 1
  15.    
  16. if not is_found:
  17.     print(f"The book you search is not here!\nYou checked {counter} books.")
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement