I have created a python program where customers can return book and borrow book from Library, while executing I gets error * TypeError: borrow() missing 1 required positional argument: 'self' *
What changes I should make to execute the program successfully ?
I will call returnbook() function initially as the library have no books at present.
class Library:
def __init__(self):
self.availablebook = availablebook
def reducebook(self,book):
if book in self.availablebook:
self.availablebook.remove(book)
print('book is removed')
def addbook(self,book):
self.availablebook.append(book)
print('book added')
class Customer:
def borrow(self):
print('enter book')
book = input()
Library.reducebook(book)
def returnbook(self):
print('enter book')
book = input()
Library.addbook(book)
while True:
print('enter 1 for add book,2 for borrow book,3 to exit')
self.x = int(input())
if(x==1):
Customer.borrow()
elif(x==2):
Customer.returnbook()
else:
print('exiting')
quit()
Create an instance of the Customer
class, do not use the class directly:
customer = Customer()
customer.borrow()
customer.returnbook()
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments