Spocoman

01. Old Books

Dec 27th, 2021 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. wanted_book = input()
  2. counter = 0
  3.  
  4. book = input()
  5. while book != 'No More Books' and book != wanted_book:
  6.     counter += 1
  7.     book = input()
  8.  
  9. if wanted_book == book:
  10.     print(f'You checked {counter} books and found it.')
  11. else:
  12.     print('The book you search is not here!')
  13.     print(f'You checked {counter} books.')
  14.  
  15.  
  16. РЕШЕНИЕ С FOR:
  17.  
  18. import sys
  19.  
  20. wanted_book = input()
  21.  
  22. for i in range(sys.maxsize):
  23.     book = input()
  24.     if wanted_book == book:
  25.         print(f'You checked {i} books and found it.')
  26.         break
  27.     elif book == 'No More Books':
  28.         print('The book you search is not here!')
  29.         print(f'You checked {i} books.')
  30.         break
  31.  
Add Comment
Please, Sign In to add comment