-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.py
More file actions
34 lines (23 loc) · 862 Bytes
/
Copy pathadd.py
File metadata and controls
34 lines (23 loc) · 862 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
26
27
28
29
30
31
32
33
34
from utisils import library
def add():
print("\n----ADD NEW BOOK----")
bookid = input("Enter Book ID : ")
title = input("Enter book title : ")
author = input("Enter author of the book : ")
category = input("Enter category of the book: ")
quantity = int(input("Enter the quantity: "))
if title == "" or author == "" or quantity <= 0:
print("Invalid input! Fill all fields correctly.")
for book in library:
if book["id"] == bookid:
book["quantity"] += quantity
print("Book already exists. Quantity updated.")
new_book = {
"id": bookid,
"title": title,
"author": author,
"category": category,
"quantity": quantity,
"status": "Available"
}
library.append(new_book)