-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_2_2.py
More file actions
25 lines (18 loc) · 739 Bytes
/
Copy pathmain_2_2.py
File metadata and controls
25 lines (18 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Lab No 2
'''
Task 2.2:
Implement a book search by author, using the result limitation according to your variant.
Restrictions: Up to 200 rubles
'''
import csv
def search_by_author(book_file):
book_file.seek(0)
reader = csv.DictReader(book_file, delimiter=';')
input_author_name = input("Please type the author in you want to search:")
print(f"\nThese are the books from {input_author_name} which are cheaper then 200 rubels:")
for row in reader:
if (str(row['Book-Author']) == input_author_name) and (float(row['Price'].replace(",", ".")) < 200):
booktitle = row['Book-Title']
print(booktitle)
with open('books-en.csv') as book_file:
search_by_author(book_file)