-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrrary management .py
64 lines (51 loc) · 1.93 KB
/
librrary management .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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Library:
def __init__ (self,list,name):
self.booklist = list
self.name = name
self.lendDict = {}
def displayBooks(self):
print(f"we have following books in our library: {self.name}")
for book in self.booklist:
print(book)
def lendBook(self,book,name):
if book not in self.lendDict.keys():
self.lendDict.update({book:name})
print("Lender-Book database has been updateed.you can take the book now")
else:
print(f"Book is already being used by{self.lendDict[book]}")
def addBook(self,book):
self.booklist.append(book)
print("book has been added to the book list")
def returnBook (self,book):
self.booklist.remove(book)
if __name__=='__main__':
harry = Library(['python','rich Daddypoor Daddy'],"codewithharry")
while(True):
print(f"welcome library to{harry.name} library enter choice")
print("1.Display book")
print("2.Lend a book")
print("3. Add a book")
print("4. Return a book")
user_choice = int(input())
if user_choice == 1:
harry.displayBooks()
elif user_choice == 2:
book = input("enter the name of book want to land")
name = input(" entter thr name usesr")
harry.lendBook(book,name)
elif user_choice == 3:
book = input("enter the name")
harry.addBook(book)
elif user_choice == 4:
book = input("enter the name")
harry.returnBook(book)
else:
print("not a valid option")
print(" q for quit c for countinue")
user_choice2 =" "
while(user_choice2!="c" and user_choice2!="q"):
user_choice2 = input()
if user_choice2 =="q":
exit()
elif user_choice2 =="c":
continue