-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLibrary.py
45 lines (43 loc) · 1.25 KB
/
Library.py
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
35
36
37
38
39
40
41
42
43
44
45
class Library:
def __init__(self,list,name):
self.list=list#
self.name=name
self.dic={}
def displaybooks(self):
for i in self.list:
print(i)
def lendbook(self,user,book):
if book not in self.dic.keys():
self.dic.update({book:user})
else:
print("Book is already present in list.")
def addbook(self,book):
self.list.append(book)
def returnbook(self,book):
self.dic.pop(book)
if __name__=='__main__':
j=Library(["rich","honey","jungle book"],"jashan")
while True:
print("choose a function to peform:")
i=int(input(""))
if i==1:
j.displaybooks()
elif i==2:
user=input("our id :")
book=input("which book you want to lend:")
j.lendbook(user,book)
elif i==3:
book=input("name of the book you want to add:")
j.addbook(book)
elif i==4:
book=input("book you want to return:")
else:
print("Error")
print("q to quit or c to continue")
i2=""
while i2!="q" and i2!="c":
i2=input()
if i2=="q":
exit()
elif i2=="c":
continue